annotate vidix/sis_vid.c @ 26612:87d096a58965

Check ASF packet size before calling demux_asf_read_packet. Fixes segfault with damaged ASF files.
author eugeni
date Fri, 02 May 2008 13:33:14 +0000
parents 0d255d03016f
children 051b2632f121
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23046
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
1 /*
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
2 * VIDIX driver for SiS chipsets.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
3 * Copyright (C) 2003 Jake Page, Sugar Media.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
4 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
5 * This file is part of MPlayer.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
6 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
7 * MPlayer is free software; you can redistribute it and/or modify
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
8 * it under the terms of the GNU General Public License as published by
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
10 * (at your option) any later version.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
11 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
12 * MPlayer is distributed in the hope that it will be useful,
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
15 * GNU General Public License for more details.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
16 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
17 * You should have received a copy of the GNU General Public License
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
18 * along with MPlayer; if not, write to the Free Software
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
20 *
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
21 * Based on SiS Xv driver
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
22 * Copyright 2002-2003 by Thomas Winischhofer, Vienna, Austria.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
23 * 2003/10/08 integrated into mplayer/vidix architecture -- Alex Beregszaszi
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
24 */
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
25
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
26 #include <errno.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
27 #include <stdio.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
28 #include <stdlib.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
29 #include <string.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
30 #include <inttypes.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
31 #include <unistd.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
32
26203
0d255d03016f #include config.h before all other headers.
diego
parents: 23260
diff changeset
33 #include "config.h"
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
34 #include "vidix.h"
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
35 #include "vidixlib.h"
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
36 #include "fourcc.h"
22901
a7605669b114 renamed libdha.[hc] to dha.[hc]
ben
parents: 22900
diff changeset
37 #include "dha.h"
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents: 22867
diff changeset
38 #include "pci_ids.h"
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents: 22867
diff changeset
39 #include "pci_names.h"
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
40
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
41 #include "sis_regs.h"
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
42 #include "sis_defs.h"
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
43
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
44
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
45 /** Random defines **/
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
46
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
47 #define WATCHDOG_DELAY 500000 /* Watchdog counter for retrace waiting */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
48 #define IMAGE_MIN_WIDTH 32 /* Min and max source image sizes */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
49 #define IMAGE_MIN_HEIGHT 24
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
50 #define IMAGE_MAX_WIDTH 720
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
51 #define IMAGE_MAX_HEIGHT 576
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
52 #define IMAGE_MAX_WIDTH_M650 1920
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
53 #define IMAGE_MAX_HEIGHT_M650 1080
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
54
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
55 #define OVERLAY_MIN_WIDTH 32 /* Minimum overlay sizes */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
56 #define OVERLAY_MIN_HEIGHT 24
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
57
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
58 #define DISPMODE_SINGLE1 0x1 /* TW: CRT1 only */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
59 #define DISPMODE_SINGLE2 0x2 /* TW: CRT2 only */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
60 #define DISPMODE_MIRROR 0x4 /* TW: CRT1 + CRT2 MIRROR */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
61
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
62 #define VMODE_INTERLACED 0x1
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
63 #define VMODE_DOUBLESCAN 0x2
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
64
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
65 typedef struct {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
66 short x1, y1, x2, y2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
67 } BoxRec;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
68
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
69 typedef struct {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
70 int pixelFormat;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
71
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
72 uint16_t pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
73 uint16_t origPitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
74
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
75 uint8_t keyOP;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
76 uint16_t HUSF;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
77 uint16_t VUSF;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
78 uint8_t IntBit;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
79 uint8_t wHPre;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
80
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
81 uint16_t srcW;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
82 uint16_t srcH;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
83
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
84 BoxRec dstBox;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
85
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
86 uint32_t PSY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
87 uint32_t PSV;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
88 uint32_t PSU;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
89 uint8_t bobEnable;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
90
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
91 uint8_t contrastCtrl;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
92 uint8_t contrastFactor;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
93
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
94 uint8_t lineBufSize;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
95
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
96 uint8_t(*VBlankActiveFunc) ();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
97
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
98 uint16_t SCREENheight;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
99
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
100 } SISOverlayRec, *SISOverlayPtr;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
101
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
102
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
103 /** static variable definitions **/
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
104 static int sis_probed = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
105 static pciinfo_t pci_info;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
106 unsigned int sis_verbose = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
107
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
108 static void *sis_mem_base;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
109 /* static void *sis_reg_base; */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
110 unsigned short sis_iobase;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
111
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
112 unsigned int sis_vga_engine = UNKNOWN_VGA;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
113 static unsigned int sis_displaymode = DISPMODE_SINGLE1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
114 static unsigned int sis_has_two_overlays = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
115 static unsigned int sis_bridge_is_slave = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
116 static unsigned int sis_shift_value = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
117 static unsigned int sis_vmode = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
118 unsigned int sis_vbflags = DISPTYPE_DISP1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
119 unsigned int sis_overlay_on_crt1 = 1;
22867
d76307ffcb77 killed warnings in sis driver
ben
parents: 22858
diff changeset
120 int sis_crt1_off = -1;
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
121 unsigned int sis_detected_crt2_devices;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
122 unsigned int sis_force_crt2_type = CRT2_DEFAULT;
22867
d76307ffcb77 killed warnings in sis driver
ben
parents: 22858
diff changeset
123 int sis_device_id = -1;
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
124
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
125 static int sis_format;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
126 static int sis_Yoff = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
127 static int sis_Voff = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
128 static int sis_Uoff = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
129 static int sis_screen_width = 640;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
130 static int sis_screen_height = 480;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
131
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
132 static int sis_frames[VID_PLAY_MAXFRAMES];
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
133
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
134 static vidix_grkey_t sis_grkey;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
135
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
136 static vidix_capability_t sis_cap = {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
137 "SiS 300/310/325 Video Driver",
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
138 "Jake Page",
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
139 TYPE_OUTPUT,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
140 {0, 0, 0, 0},
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
141 2048,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
142 2048,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
143 4,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
144 4,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
145 -1,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
146 FLAG_UPSCALER | FLAG_DOWNSCALER | FLAG_EQUALIZER,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
147 VENDOR_SIS,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
148 -1,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
149 {0, 0, 0, 0}
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
150 };
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
151
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
152 static vidix_video_eq_t sis_equal = {
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
153 VEQ_CAP_BRIGHTNESS | VEQ_CAP_CONTRAST,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
154 200, 0, 0, 0, 0, 0, 0, 0
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
155 };
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
156
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
157 static unsigned short sis_card_ids[] = {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
158 DEVICE_SIS_300,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
159 DEVICE_SIS_315H,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
160 DEVICE_SIS_315,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
161 DEVICE_SIS_315PRO,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
162 DEVICE_SIS_330,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
163 DEVICE_SIS_540_VGA,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
164 DEVICE_SIS_550_VGA,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
165 DEVICE_SIS_630_VGA,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
166 DEVICE_SIS_650_VGA
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
167 };
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
168
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
169 /** function declarations **/
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
170
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
171 extern void sis_init_video_bridge(void);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
172
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
173
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
174 static void set_overlay(SISOverlayPtr pOverlay, int index);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
175 static void close_overlay(void);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
176 static void calc_scale_factor(SISOverlayPtr pOverlay,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
177 int index, int iscrt2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
178 static void set_line_buf_size(SISOverlayPtr pOverlay);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
179 static void merge_line_buf(int enable);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
180 static void set_format(SISOverlayPtr pOverlay);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
181 static void set_colorkey(void);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
182
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
183 static void set_brightness(uint8_t brightness);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
184 static void set_contrast(uint8_t contrast);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
185 static void set_saturation(char saturation);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
186 static void set_hue(uint8_t hue);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
187
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
188 /* IO Port access functions */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
189 static uint8_t getvideoreg(uint8_t reg)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
190 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
191 uint8_t ret;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
192 inSISIDXREG(SISVID, reg, ret);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
193 return (ret);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
194 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
195
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
196 static void setvideoreg(uint8_t reg, uint8_t data)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
197 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
198 outSISIDXREG(SISVID, reg, data);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
199 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
200
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
201 static void setvideoregmask(uint8_t reg, uint8_t data, uint8_t mask)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
202 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
203 uint8_t old;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
204
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
205 inSISIDXREG(SISVID, reg, old);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
206 data = (data & mask) | (old & (~mask));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
207 outSISIDXREG(SISVID, reg, data);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
208 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
209
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
210 static void setsrregmask(uint8_t reg, uint8_t data, uint8_t mask)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
211 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
212 uint8_t old;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
213
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
214 inSISIDXREG(SISSR, reg, old);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
215 data = (data & mask) | (old & (~mask));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
216 outSISIDXREG(SISSR, reg, data);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
217 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
218
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
219 /* vblank checking*/
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
220 static uint8_t vblank_active_CRT1(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
221 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
222 /* this may be too simplistic? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
223 return (inSISREG(SISINPSTAT) & 0x08);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
224 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
225
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
226 static uint8_t vblank_active_CRT2(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
227 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
228 uint8_t ret;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
229 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
230 inSISIDXREG(SISPART1, Index_310_CRT2_FC_VR, ret);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
231 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
232 inSISIDXREG(SISPART1, Index_CRT2_FC_VR, ret);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
233 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
234 return ((ret & 0x02) ^ 0x02);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
235 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
236
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
237 static int find_chip(unsigned chip_id)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
238 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
239 unsigned i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
240 for (i = 0; i < sizeof(sis_card_ids) / sizeof(unsigned short); i++) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
241 if (chip_id == sis_card_ids[i])
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
242 return i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
243 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
244 return -1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
245 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
246
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
247 static int sis_probe(int verbose, int force)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
248 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
249 pciinfo_t lst[MAX_PCI_DEVICES];
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
250 unsigned i, num_pci;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
251 int err;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
252
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
253 sis_verbose = verbose;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
254 force = force;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
255 err = pci_scan(lst, &num_pci);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
256 if (err) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
257 printf("[SiS] Error occurred during pci scan: %s\n", strerror(err));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
258 return err;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
259 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
260 err = ENXIO;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
261 for (i = 0; i < num_pci; i++) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
262 if (lst[i].vendor == VENDOR_SIS) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
263 int idx;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
264 const char *dname;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
265 idx = find_chip(lst[i].device);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
266 if (idx == -1)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
267 continue;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
268 dname = pci_device_name(VENDOR_SIS, lst[i].device);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
269 dname = dname ? dname : "Unknown chip";
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
270 if (sis_verbose > 0)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
271 printf("[SiS] Found chip: %s (0x%X)\n",
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
272 dname, lst[i].device);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
273 sis_device_id = sis_cap.device_id = lst[i].device;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
274 err = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
275 memcpy(&pci_info, &lst[i], sizeof(pciinfo_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
276
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
277 sis_has_two_overlays = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
278 switch (sis_cap.device_id) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
279 case DEVICE_SIS_300:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
280 case DEVICE_SIS_630_VGA:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
281 sis_has_two_overlays = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
282 case DEVICE_SIS_540_VGA:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
283 sis_vga_engine = SIS_300_VGA;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
284 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
285 case DEVICE_SIS_330:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
286 case DEVICE_SIS_550_VGA:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
287 sis_has_two_overlays = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
288 case DEVICE_SIS_315H:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
289 case DEVICE_SIS_315:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
290 case DEVICE_SIS_315PRO:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
291 case DEVICE_SIS_650_VGA:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
292 /* M650 & 651 have 2 overlays */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
293 /* JCP: I think this works, but not really tested yet */
23260
427075ffb413 allow sis vidix driver to access registers and avoid segfaulting (patch by Andrew Calkin)
ben
parents: 23048
diff changeset
294 if (enable_app_io() == 0 )
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
295 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
296 unsigned char CR5F;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
297 unsigned char tempreg1, tempreg2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
298
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
299 inSISIDXREG(SISCR, 0x5F, CR5F);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
300 CR5F &= 0xf0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
301 andSISIDXREG(SISCR, 0x5c, 0x07);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
302 inSISIDXREG(SISCR, 0x5c, tempreg1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
303 tempreg1 &= 0xf8;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
304 setSISIDXREG(SISCR, 0x5c, 0x07, 0xf8);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
305 inSISIDXREG(SISCR, 0x5c, tempreg2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
306 tempreg2 &= 0xf8;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
307 if ((!tempreg1) || (tempreg2)) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
308 if (CR5F & 0x80) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
309 sis_has_two_overlays = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
310 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
311 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
312 sis_has_two_overlays = 1; /* ? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
313 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
314 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
315 if (sis_verbose > 0)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
316 printf
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
317 ("[SiS] detected M650/651 with 2 overlays\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
318 }
23260
427075ffb413 allow sis vidix driver to access registers and avoid segfaulting (patch by Andrew Calkin)
ben
parents: 23048
diff changeset
319 disable_app_io();
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
320 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
321 sis_vga_engine = SIS_315_VGA;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
322 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
323 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
324 /* should never get here */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
325 sis_vga_engine = UNKNOWN_VGA;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
326 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
327 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
328 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
329 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
330 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
331 if (err && sis_verbose) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
332 printf("[SiS] Can't find chip\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
333 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
334 sis_probed = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
335 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
336
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
337 return err;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
338 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
339
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
340 static int sis_init(void)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
341 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
342 uint8_t sr_data, cr_data, cr_data2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
343 char *env_overlay_crt;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
344
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
345 if (!sis_probed) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
346 printf("[SiS] driver was not probed but is being initialized\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
347 return (EINTR);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
348 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
349
23260
427075ffb413 allow sis vidix driver to access registers and avoid segfaulting (patch by Andrew Calkin)
ben
parents: 23048
diff changeset
350 if (enable_app_io() != 0)
427075ffb413 allow sis vidix driver to access registers and avoid segfaulting (patch by Andrew Calkin)
ben
parents: 23048
diff changeset
351 {
427075ffb413 allow sis vidix driver to access registers and avoid segfaulting (patch by Andrew Calkin)
ben
parents: 23048
diff changeset
352 printf("[SiS] can't enable register I/O\n");
427075ffb413 allow sis vidix driver to access registers and avoid segfaulting (patch by Andrew Calkin)
ben
parents: 23048
diff changeset
353 return(EINTR);
427075ffb413 allow sis vidix driver to access registers and avoid segfaulting (patch by Andrew Calkin)
ben
parents: 23048
diff changeset
354 }
427075ffb413 allow sis vidix driver to access registers and avoid segfaulting (patch by Andrew Calkin)
ben
parents: 23048
diff changeset
355
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
356 /* JCP: this is WRONG. Need to coordinate w/ sisfb to use correct mem */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
357 /* map 16MB scary hack for now. */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
358 sis_mem_base = map_phys_mem(pci_info.base0, 0x1000000);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
359 /* sis_reg_base = map_phys_mem(pci_info.base1, 0x20000); */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
360 sis_iobase = pci_info.base2 & 0xFFFC;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
361
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
362 /* would like to use fb ioctl - or some other method - here to get
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
363 current resolution. */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
364 inSISIDXREG(SISCR, 0x12, cr_data);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
365 inSISIDXREG(SISCR, 0x07, cr_data2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
366 sis_screen_height =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
367 ((cr_data & 0xff) | ((uint16_t) (cr_data2 & 0x02) << 7) |
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
368 ((uint16_t) (cr_data2 & 0x40) << 3) | ((uint16_t) (cr_data & 0x02)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
369 << 9)) + 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
370
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
371 inSISIDXREG(SISSR, 0x0b, sr_data);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
372 inSISIDXREG(SISCR, 0x01, cr_data);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
373 sis_screen_width = (((cr_data & 0xff) |
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
374 ((uint16_t) (sr_data & 0x0C) << 6)) + 1) * 8;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
375
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
376 inSISIDXREG(SISSR, Index_SR_Graphic_Mode, sr_data);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
377 if (sr_data & 0x20) /* interlaced mode */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
378 sis_vmode |= VMODE_INTERLACED;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
379
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
380 /* JCP: eventually I'd like to replace this with a call to sisfb
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
381 SISFB_GET_INFO ioctl to get video bridge info. Not for now,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
382 since it requires a very new and not widely distributed version. */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
383 sis_init_video_bridge();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
384
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
385 env_overlay_crt = getenv("VIDIX_CRT");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
386 if (env_overlay_crt) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
387 int crt = atoi(env_overlay_crt);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
388 if (crt == 1 || crt == 2) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
389 sis_overlay_on_crt1 = (crt == 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
390 if (sis_verbose > 0) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
391 printf
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
392 ("[SiS] override: using overlay on CRT%d from VIDIX_CRT\n",
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
393 crt);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
394 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
395 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
396 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
397
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
398 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
399 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
400
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
401 static void sis_destroy(void)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
402 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
403 /* unmap_phys_mem(sis_reg_base, 0x20000); */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
404 /* JCP: see above, hence also a hack. */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
405 unmap_phys_mem(sis_mem_base, 0x1000000);
23260
427075ffb413 allow sis vidix driver to access registers and avoid segfaulting (patch by Andrew Calkin)
ben
parents: 23048
diff changeset
406 disable_app_io();
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
407 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
408
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
409 static int sis_get_caps(vidix_capability_t * to)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
410 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
411 memcpy(to, &sis_cap, sizeof(vidix_capability_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
412 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
413 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
414
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
415 static int is_supported_fourcc(uint32_t fourcc)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
416 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
417 switch (fourcc) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
418 case IMGFMT_YV12:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
419 case IMGFMT_I420:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
420 case IMGFMT_UYVY:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
421 case IMGFMT_YUY2:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
422 case IMGFMT_RGB15:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
423 case IMGFMT_RGB16:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
424 return 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
425 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
426 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
427 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
428 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
429
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
430 static int sis_query_fourcc(vidix_fourcc_t * to)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
431 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
432 if (is_supported_fourcc(to->fourcc)) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
433 to->depth = VID_DEPTH_8BPP | VID_DEPTH_16BPP | VID_DEPTH_32BPP;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
434 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
435 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
436 } else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
437 to->depth = to->flags = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
438 return ENOSYS;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
439 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
440
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
441 static int bridge_in_slave_mode(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
442 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
443 unsigned char usScratchP1_00;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
444
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
445 if (!(sis_vbflags & VB_VIDEOBRIDGE))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
446 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
447
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
448 inSISIDXREG(SISPART1, 0x00, usScratchP1_00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
449 if (((sis_vga_engine == SIS_300_VGA)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
450 && (usScratchP1_00 & 0xa0) == 0x20)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
451 || ((sis_vga_engine == SIS_315_VGA)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
452 && (usScratchP1_00 & 0x50) == 0x10)) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
453 return 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
454 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
455 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
456 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
457 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
458
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
459 /* This does not handle X dual head mode, since 1) vidix doesn't support it
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
460 and 2) it doesn't make sense for other gfx drivers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
461 static void set_dispmode(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
462 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
463 sis_bridge_is_slave = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
464
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
465 if (bridge_in_slave_mode())
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
466 sis_bridge_is_slave = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
467
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
468 if ((sis_vbflags & VB_DISPMODE_MIRROR) ||
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
469 (sis_bridge_is_slave && (sis_vbflags & DISPTYPE_DISP2))) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
470 if (sis_has_two_overlays)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
471 sis_displaymode = DISPMODE_MIRROR; /* TW: CRT1+CRT2 (2 overlays) */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
472 else if (!sis_overlay_on_crt1)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
473 sis_displaymode = DISPMODE_SINGLE2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
474 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
475 sis_displaymode = DISPMODE_SINGLE1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
476 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
477 if (sis_vbflags & DISPTYPE_DISP1) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
478 sis_displaymode = DISPMODE_SINGLE1; /* TW: CRT1 only */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
479 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
480 sis_displaymode = DISPMODE_SINGLE2; /* TW: CRT2 only */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
481 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
482 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
483 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
484
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
485 static void set_disptype_regs(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
486 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
487 switch (sis_displaymode) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
488 case DISPMODE_SINGLE1: /* TW: CRT1 only */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
489 if (sis_verbose > 2) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
490 printf("[SiS] Setting up overlay on CRT1\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
491 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
492 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
493 setsrregmask(0x06, 0x00, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
494 setsrregmask(0x32, 0x00, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
495 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
496 setsrregmask(0x06, 0x00, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
497 setsrregmask(0x32, 0x00, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
498 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
499 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
500 case DISPMODE_SINGLE2: /* TW: CRT2 only */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
501 if (sis_verbose > 2) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
502 printf("[SiS] Setting up overlay on CRT2\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
503 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
504 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
505 setsrregmask(0x06, 0x80, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
506 setsrregmask(0x32, 0x80, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
507 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
508 setsrregmask(0x06, 0x40, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
509 setsrregmask(0x32, 0x40, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
510 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
511 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
512 case DISPMODE_MIRROR: /* TW: CRT1 + CRT2 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
513 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
514 if (sis_verbose > 2) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
515 printf("[SiS] Setting up overlay on CRT1 AND CRT2!\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
516 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
517 setsrregmask(0x06, 0x80, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
518 setsrregmask(0x32, 0x80, 0xc0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
519 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
520 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
521 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
522
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
523 static void init_overlay(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
524 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
525 /* Initialize first overlay (CRT1) */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
526
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
527 /* Write-enable video registers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
528 setvideoregmask(Index_VI_Control_Misc2, 0x80, 0x81);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
529
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
530 /* Disable overlay */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
531 setvideoregmask(Index_VI_Control_Misc0, 0x00, 0x02);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
532
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
533 /* Disable bobEnable */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
534 setvideoregmask(Index_VI_Control_Misc1, 0x02, 0x02);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
535
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
536 /* Reset scale control and contrast */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
537 setvideoregmask(Index_VI_Scale_Control, 0x60, 0x60);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
538 setvideoregmask(Index_VI_Contrast_Enh_Ctrl, 0x04, 0x1F);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
539
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
540 setvideoreg(Index_VI_Disp_Y_Buf_Preset_Low, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
541 setvideoreg(Index_VI_Disp_Y_Buf_Preset_Middle, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
542 setvideoreg(Index_VI_UV_Buf_Preset_Low, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
543 setvideoreg(Index_VI_UV_Buf_Preset_Middle, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
544 setvideoreg(Index_VI_Disp_Y_UV_Buf_Preset_High, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
545 setvideoreg(Index_VI_Play_Threshold_Low, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
546 setvideoreg(Index_VI_Play_Threshold_High, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
547
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
548 /* may not want to init these here, could already be set to other
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
549 values by app? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
550 setvideoregmask(Index_VI_Control_Misc2, 0x00, 0x01);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
551 setvideoregmask(Index_VI_Contrast_Enh_Ctrl, 0x04, 0x07);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
552 setvideoreg(Index_VI_Brightness, 0x20);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
553 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
554 setvideoreg(Index_VI_Hue, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
555 setvideoreg(Index_VI_Saturation, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
556 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
557
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
558 /* Initialize second overlay (CRT2) */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
559 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
560 /* Write-enable video registers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
561 setvideoregmask(Index_VI_Control_Misc2, 0x81, 0x81);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
562
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
563 /* Disable overlay */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
564 setvideoregmask(Index_VI_Control_Misc0, 0x00, 0x02);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
565
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
566 /* Disable bobEnable */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
567 setvideoregmask(Index_VI_Control_Misc1, 0x02, 0x02);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
568
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
569 /* Reset scale control and contrast */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
570 setvideoregmask(Index_VI_Scale_Control, 0x60, 0x60);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
571 setvideoregmask(Index_VI_Contrast_Enh_Ctrl, 0x04, 0x1F);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
572
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
573 setvideoreg(Index_VI_Disp_Y_Buf_Preset_Low, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
574 setvideoreg(Index_VI_Disp_Y_Buf_Preset_Middle, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
575 setvideoreg(Index_VI_UV_Buf_Preset_Low, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
576 setvideoreg(Index_VI_UV_Buf_Preset_Middle, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
577 setvideoreg(Index_VI_Disp_Y_UV_Buf_Preset_High, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
578 setvideoreg(Index_VI_Play_Threshold_Low, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
579 setvideoreg(Index_VI_Play_Threshold_High, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
580
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
581 setvideoregmask(Index_VI_Control_Misc2, 0x01, 0x01);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
582 setvideoregmask(Index_VI_Contrast_Enh_Ctrl, 0x04, 0x07);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
583 setvideoreg(Index_VI_Brightness, 0x20);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
584 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
585 setvideoreg(Index_VI_Hue, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
586 setvideoreg(Index_VI_Saturation, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
587 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
588 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
589 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
590
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
591 static int sis_set_eq(const vidix_video_eq_t * eq);
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
592
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
593 static int sis_config_playback(vidix_playback_t * info)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
594 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
595 SISOverlayRec overlay;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
596 int srcOffsetX = 0, srcOffsetY = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
597 int sx, sy;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
598 int index = 0, iscrt2 = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
599 int total_size;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
600
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
601 short src_w, drw_w;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
602 short src_h, drw_h;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
603 short src_x, drw_x;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
604 short src_y, drw_y;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
605 long dga_offset;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
606 int pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
607 unsigned int i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
608
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
609 if (!is_supported_fourcc(info->fourcc))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
610 return -1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
611
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
612 /* set chipset/engine.dependent config info */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
613 /* which CRT to use, etc.? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
614 switch (sis_vga_engine) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
615 case SIS_315_VGA:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
616 sis_shift_value = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
617 sis_equal.cap |= VEQ_CAP_SATURATION | VEQ_CAP_HUE;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
618 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
619 case SIS_300_VGA:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
620 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
621 sis_shift_value = 2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
622 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
623 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
624
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
625 sis_displaymode = DISPMODE_SINGLE1; /* xV driver code in set_dispmode() */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
626 set_dispmode();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
627
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
628 set_disptype_regs();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
629
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
630 init_overlay();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
631
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
632 /* get basic dimension info */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
633 src_x = info->src.x;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
634 src_y = info->src.y;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
635 src_w = info->src.w;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
636 src_h = info->src.h;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
637
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
638 drw_x = info->dest.x;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
639 drw_y = info->dest.y;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
640 drw_w = info->dest.w;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
641 drw_h = info->dest.h;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
642
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
643 switch (info->fourcc) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
644 case IMGFMT_YV12:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
645 case IMGFMT_I420:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
646 pitch = (src_w + 7) & ~7;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
647 total_size = (pitch * src_h * 3) >> 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
648 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
649 case IMGFMT_YUY2:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
650 case IMGFMT_UYVY:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
651 case IMGFMT_RGB15:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
652 case IMGFMT_RGB16:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
653 pitch = ((src_w << 1) + 3) & ~3;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
654 total_size = pitch * src_h;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
655 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
656 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
657 return -1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
658 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
659
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
660 /* "allocate" memory for overlay! */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
661 /* start at 8MB = sisfb's "dri reserved space" -
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
662 really shouldn't hardcode though */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
663 /* XXX: JCP - this can use the sisfb FBIO_ALLOC ioctl to safely
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
664 allocate "video heap" memory... */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
665 dga_offset = 0x800000;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
666
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
667 /* use 7MB for now. need to calc/get real info from sisfb? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
668 /* this can result in a LOT of frames - probably not necessary */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
669 info->num_frames = 0x700000 / (total_size * 2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
670 if (info->num_frames > VID_PLAY_MAXFRAMES)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
671 info->num_frames = VID_PLAY_MAXFRAMES;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
672
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
673 info->dga_addr = sis_mem_base + dga_offset;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
674 info->dest.pitch.y = 16;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
675 info->dest.pitch.u = 16;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
676 info->dest.pitch.v = 16;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
677 info->offset.y = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
678 info->offset.u = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
679 info->offset.v = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
680 info->frame_size = (total_size * 2); /* why times 2 ? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
681 for (i = 0; i < info->num_frames; i++) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
682 info->offsets[i] = info->frame_size * i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
683 /* save ptrs to mem buffers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
684 sis_frames[i] = (dga_offset + info->offsets[i]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
685 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
686
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
687 memset(&overlay, 0, sizeof(overlay));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
688 overlay.pixelFormat = sis_format = info->fourcc;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
689 overlay.pitch = overlay.origPitch = pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
690
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
691
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
692 overlay.keyOP = (sis_grkey.ckey.op == CKEY_TRUE ?
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
693 VI_ROP_DestKey : VI_ROP_Always);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
694
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
695 overlay.bobEnable = 0x00;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
696
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
697 overlay.SCREENheight = sis_screen_height;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
698
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
699 /* probably will not support X virtual screen > phys very well? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
700 overlay.dstBox.x1 = drw_x; /* - pScrn->frameX0; */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
701 overlay.dstBox.x2 = drw_x + drw_w; /* - pScrn->frameX0; ??? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
702 overlay.dstBox.y1 = drw_y; /* - pScrn->frameY0; */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
703 overlay.dstBox.y2 = drw_y + drw_h; /* - pScrn->frameY0; ??? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
704
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
705 if ((overlay.dstBox.x1 > overlay.dstBox.x2) ||
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
706 (overlay.dstBox.y1 > overlay.dstBox.y2))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
707 return -1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
708
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
709 if ((overlay.dstBox.x2 < 0) || (overlay.dstBox.y2 < 0))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
710 return -1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
711
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
712 if (overlay.dstBox.x1 < 0) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
713 srcOffsetX = src_w * (-overlay.dstBox.x1) / drw_w;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
714 overlay.dstBox.x1 = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
715 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
716 if (overlay.dstBox.y1 < 0) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
717 srcOffsetY = src_h * (-overlay.dstBox.y1) / drw_h;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
718 overlay.dstBox.y1 = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
719 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
720
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
721 switch (info->fourcc) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
722 case IMGFMT_YV12:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
723 info->dest.pitch.y = 16;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
724 sx = (src_x + srcOffsetX) & ~7;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
725 sy = (src_y + srcOffsetY) & ~1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
726 info->offset.y = sis_Yoff = sx + sy * pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
727 /* JCP: NOTE reversed u & v here! Not sure why this is needed.
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
728 maybe mplayer & sis define U & V differently?? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
729 info->offset.u = sis_Voff =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
730 src_h * pitch + ((sx + sy * pitch / 2) >> 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
731 info->offset.v = sis_Uoff =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
732 src_h * pitch * 5 / 4 + ((sx + sy * pitch / 2) >> 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
733
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
734 overlay.PSY = (sis_frames[0] + sis_Yoff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
735 overlay.PSV = (sis_frames[0] + sis_Voff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
736 overlay.PSU = (sis_frames[0] + sis_Uoff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
737 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
738 case IMGFMT_I420:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
739 sx = (src_x + srcOffsetX) & ~7;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
740 sy = (src_y + srcOffsetY) & ~1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
741 info->offset.y = sis_Yoff = sx + sy * pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
742 /* JCP: see above... */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
743 info->offset.u = sis_Voff =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
744 src_h * pitch * 5 / 4 + ((sx + sy * pitch / 2) >> 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
745 info->offset.v = sis_Uoff =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
746 src_h * pitch + ((sx + sy * pitch / 2) >> 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
747
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
748 overlay.PSY = (sis_frames[0] + sis_Yoff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
749 overlay.PSV = (sis_frames[0] + sis_Voff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
750 overlay.PSU = (sis_frames[0] + sis_Uoff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
751 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
752 case IMGFMT_YUY2:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
753 case IMGFMT_UYVY:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
754 case IMGFMT_RGB16:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
755 case IMGFMT_RGB15:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
756 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
757 sx = (src_x + srcOffsetX) & ~1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
758 sy = (src_y + srcOffsetY);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
759 info->offset.y = sis_Yoff = sx * 2 + sy * pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
760
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
761 overlay.PSY = (sis_frames[0] + sis_Yoff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
762 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
763 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
764
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
765 /* FIXME: is it possible that srcW < 0? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
766 overlay.srcW = src_w - (sx - src_x);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
767 overlay.srcH = src_h - (sy - src_y);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
768
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
769 /* set merge line buffer */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
770 merge_line_buf(overlay.srcW > 384);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
771
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
772 /* calculate line buffer length */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
773 set_line_buf_size(&overlay);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
774
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
775 if (sis_displaymode == DISPMODE_SINGLE2) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
776 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
777 /* TW: On chips with two overlays we use
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
778 * overlay 2 for CRT2 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
779 index = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
780 iscrt2 = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
781 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
782 /* TW: On chips with only one overlay we
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
783 * use that only overlay for CRT2 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
784 index = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
785 iscrt2 = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
786 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
787 overlay.VBlankActiveFunc = vblank_active_CRT2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
788 /* overlay.GetScanLineFunc = get_scanline_CRT2; */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
789 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
790 index = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
791 iscrt2 = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
792 overlay.VBlankActiveFunc = vblank_active_CRT1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
793 /* overlay.GetScanLineFunc = get_scanline_CRT1; */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
794 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
795
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
796 /* calc scale factor (to use below) */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
797 calc_scale_factor(&overlay, index, iscrt2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
798
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
799 /* Select video1 (used for CRT1) or video2 (used for CRT2) */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
800 setvideoregmask(Index_VI_Control_Misc2, index, 0x01);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
801
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
802 set_format(&overlay);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
803
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
804 set_colorkey();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
805
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
806 sis_set_eq(&sis_equal);
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
807
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
808 /* set up video overlay registers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
809 set_overlay(&overlay, index);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
810
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
811 /* prevent badness if bits are not at default setting */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
812 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x01);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
813 setvideoregmask(Index_VI_Control_Misc2, 0x00, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
814
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
815 /* JCP: Xv driver implementation loops back over above code to
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
816 setup mirror CRT2 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
817
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
818 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
819 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
820
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
821 static int sis_playback_on(void)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
822 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
823 setvideoregmask(Index_VI_Control_Misc0, 0x02, 0x02);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
824 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
825 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
826
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
827 static int sis_playback_off(void)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
828 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
829 unsigned char sridx, cridx;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
830 sridx = inSISREG(SISSR);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
831 cridx = inSISREG(SISCR);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
832 close_overlay();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
833 outSISREG(SISSR, sridx);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
834 outSISREG(SISCR, cridx);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
835
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
836 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
837 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
838
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
839 static int sis_frame_select(unsigned int frame)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
840 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
841 uint8_t data;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
842 int index = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
843 uint32_t PSY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
844
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
845 if (sis_displaymode == DISPMODE_SINGLE2 && sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
846 index = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
847 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
848
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
849 PSY = (sis_frames[frame] + sis_Yoff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
851 /* Unlock address registers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
852 data = getvideoreg(Index_VI_Control_Misc1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
853 setvideoreg(Index_VI_Control_Misc1, data | 0x20);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
854 /* TEST: Is this required? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
855 setvideoreg(Index_VI_Control_Misc1, data | 0x20);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
856 /* TEST end */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
857 /* TEST: Is this required? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
858 if (sis_vga_engine == SIS_315_VGA)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
859 setvideoreg(Index_VI_Control_Misc3, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
860 /* TEST end */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
861
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
862 /* set Y start address */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
863 setvideoreg(Index_VI_Disp_Y_Buf_Start_Low, (uint8_t) (PSY));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
864 setvideoreg(Index_VI_Disp_Y_Buf_Start_Middle, (uint8_t) ((PSY) >> 8));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
865 setvideoreg(Index_VI_Disp_Y_Buf_Start_High, (uint8_t) ((PSY) >> 16));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
866 /* set 310/325 series overflow bits for Y plane */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
867 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
868 setvideoreg(Index_VI_Y_Buf_Start_Over,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
869 ((uint8_t) ((PSY) >> 24) & 0x01));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
870 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
871
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
872 /* Set U/V data if using plane formats */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
873 if ((sis_format == IMGFMT_YV12) || (sis_format == IMGFMT_I420)) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
874
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
875 uint32_t PSU, PSV;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
876
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
877 PSU = (sis_frames[frame] + sis_Uoff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
878 PSV = (sis_frames[frame] + sis_Voff) >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
879
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
880 /* set U/V start address */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
881 setvideoreg(Index_VI_U_Buf_Start_Low, (uint8_t) PSU);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
882 setvideoreg(Index_VI_U_Buf_Start_Middle, (uint8_t) (PSU >> 8));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
883 setvideoreg(Index_VI_U_Buf_Start_High, (uint8_t) (PSU >> 16));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
884
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
885 setvideoreg(Index_VI_V_Buf_Start_Low, (uint8_t) PSV);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
886 setvideoreg(Index_VI_V_Buf_Start_Middle, (uint8_t) (PSV >> 8));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
887 setvideoreg(Index_VI_V_Buf_Start_High, (uint8_t) (PSV >> 16));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
888
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
889 /* 310/325 series overflow bits */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
890 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
891 setvideoreg(Index_VI_U_Buf_Start_Over,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
892 ((uint8_t) (PSU >> 24) & 0x01));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
893 setvideoreg(Index_VI_V_Buf_Start_Over,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
894 ((uint8_t) (PSV >> 24) & 0x01));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
895 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
896 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
897
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
898 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
899 /* Trigger register copy for 310 series */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
900 setvideoreg(Index_VI_Control_Misc3, 1 << index);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
901 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
902
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
903 /* Lock the address registers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
904 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x20);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
905
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
906 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
907 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
908
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
909 static int sis_get_gkeys(vidix_grkey_t * grkey)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
910 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
911 memcpy(grkey, &sis_grkey, sizeof(vidix_grkey_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
912 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
913 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
914
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
915 static int sis_set_gkeys(const vidix_grkey_t * grkey)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
916 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
917 memcpy(&sis_grkey, grkey, sizeof(vidix_grkey_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
918 set_colorkey();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
919 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
920 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
921
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
922 static int sis_get_eq(vidix_video_eq_t * eq)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
923 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
924 memcpy(eq, &sis_equal, sizeof(vidix_video_eq_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
925 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
926 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
927
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
928 static int sis_set_eq(const vidix_video_eq_t * eq)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
929 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
930 int br, sat, cr, hue;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
931 if (eq->cap & VEQ_CAP_BRIGHTNESS)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
932 sis_equal.brightness = eq->brightness;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
933 if (eq->cap & VEQ_CAP_CONTRAST)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
934 sis_equal.contrast = eq->contrast;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
935 if (eq->cap & VEQ_CAP_SATURATION)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
936 sis_equal.saturation = eq->saturation;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
937 if (eq->cap & VEQ_CAP_HUE)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
938 sis_equal.hue = eq->hue;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
939 if (eq->cap & VEQ_CAP_RGB_INTENSITY) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
940 sis_equal.red_intensity = eq->red_intensity;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
941 sis_equal.green_intensity = eq->green_intensity;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
942 sis_equal.blue_intensity = eq->blue_intensity;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
943 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
944 sis_equal.flags = eq->flags;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
945
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
946 cr = (sis_equal.contrast + 1000) * 7 / 2000;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
947 if (cr < 0)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
948 cr = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
949 if (cr > 7)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
950 cr = 7;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
951
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
952 br = sis_equal.brightness * 127 / 1000;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
953 if (br < -128)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
954 br = -128;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
955 if (br > 127)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
956 br = 127;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
957
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
958 sat = (sis_equal.saturation * 7) / 1000;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
959 if (sat < -7)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
960 sat = -7;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
961 if (sat > 7)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
962 sat = 7;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
963
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
964 hue = sis_equal.hue * 7 / 1000;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
965 if (hue < -8)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
966 hue = -8;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
967 if (hue > 7)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
968 hue = 7;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
969
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
970 set_brightness(br);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
971 set_contrast(cr);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
972 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
973 set_saturation(sat);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
974 set_hue(hue);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
975 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
976
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
977 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
978 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
979
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
980 static void set_overlay(SISOverlayPtr pOverlay, int index)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
981 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
982 uint16_t pitch = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
983 uint8_t h_over = 0, v_over = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
984 uint16_t top, bottom, left, right;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
985 uint16_t screenX = sis_screen_width;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
986 uint16_t screenY = sis_screen_height;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
987 uint8_t data;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
988 uint32_t watchdog;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
989
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
990 top = pOverlay->dstBox.y1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
991 bottom = pOverlay->dstBox.y2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
992 if (bottom > screenY) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
993 bottom = screenY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
994 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
995
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
996 left = pOverlay->dstBox.x1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
997 right = pOverlay->dstBox.x2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
998 if (right > screenX) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
999 right = screenX;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1000 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1001
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1002 /* JCP: these aren't really tested... */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1003 /* TW: DoubleScan modes require Y coordinates * 2 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1004 if (sis_vmode & VMODE_DOUBLESCAN) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1005 top <<= 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1006 bottom <<= 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1007 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1008 /* TW: Interlace modes require Y coordinates / 2 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1009 if (sis_vmode & VMODE_INTERLACED) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1010 top >>= 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1011 bottom >>= 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1012 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1013
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1014 h_over = (((left >> 8) & 0x0f) | ((right >> 4) & 0xf0));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1015 v_over = (((top >> 8) & 0x0f) | ((bottom >> 4) & 0xf0));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1016
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1017 pitch = pOverlay->pitch >> sis_shift_value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1018
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1019 /* set line buffer size */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1020 setvideoreg(Index_VI_Line_Buffer_Size, pOverlay->lineBufSize);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1021
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1022 /* set color key mode */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1023 setvideoregmask(Index_VI_Key_Overlay_OP, pOverlay->keyOP, 0x0F);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1024
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1025 /* TW: We don't have to wait for vertical retrace in all cases */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1026 /* JCP: be safe for now. */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1027 if (1 /*pPriv->mustwait */ ) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1028 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1029 while (pOverlay->VBlankActiveFunc() && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1030 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1031 while ((!pOverlay->VBlankActiveFunc()) && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1032 if (!watchdog && sis_verbose > 0) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1033 printf("[SiS]: timed out waiting for vertical retrace\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1034 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1035 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1036
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1037 /* Unlock address registers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1038 data = getvideoreg(Index_VI_Control_Misc1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1039 setvideoreg(Index_VI_Control_Misc1, data | 0x20);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1040 /* TEST: Is this required? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1041 setvideoreg(Index_VI_Control_Misc1, data | 0x20);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1042 /* TEST end */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1043
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1044 /* TEST: Is this required? */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1045 if (sis_vga_engine == SIS_315_VGA)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1046 setvideoreg(Index_VI_Control_Misc3, 0x00);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1047 /* TEST end */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1048
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1049 /* Set Y buf pitch */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1050 setvideoreg(Index_VI_Disp_Y_Buf_Pitch_Low, (uint8_t) (pitch));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1051 setvideoregmask(Index_VI_Disp_Y_UV_Buf_Pitch_Middle,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1052 (uint8_t) (pitch >> 8), 0x0f);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1053
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1054 /* Set Y start address */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1055 setvideoreg(Index_VI_Disp_Y_Buf_Start_Low, (uint8_t) (pOverlay->PSY));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1056 setvideoreg(Index_VI_Disp_Y_Buf_Start_Middle,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1057 (uint8_t) ((pOverlay->PSY) >> 8));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1058 setvideoreg(Index_VI_Disp_Y_Buf_Start_High,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1059 (uint8_t) ((pOverlay->PSY) >> 16));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1060
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1061 /* set 310/325 series overflow bits for Y plane */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1062 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1063 setvideoreg(Index_VI_Disp_Y_Buf_Pitch_High,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1064 (uint8_t) (pitch >> 12));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1065 setvideoreg(Index_VI_Y_Buf_Start_Over,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1066 ((uint8_t) ((pOverlay->PSY) >> 24) & 0x01));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1067 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1068
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1069 /* Set U/V data if using plane formats */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1070 if ((pOverlay->pixelFormat == IMGFMT_YV12) ||
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1071 (pOverlay->pixelFormat == IMGFMT_I420)) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1072
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1073 uint32_t PSU, PSV;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1074
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1075 PSU = pOverlay->PSU;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1076 PSV = pOverlay->PSV;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1077
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1078 /* Set U/V pitch */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1079 setvideoreg(Index_VI_Disp_UV_Buf_Pitch_Low,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1080 (uint8_t) (pitch >> 1));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1081 setvideoregmask(Index_VI_Disp_Y_UV_Buf_Pitch_Middle,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1082 (uint8_t) (pitch >> 5), 0xf0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1083
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1084 /* set U/V start address */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1085 setvideoreg(Index_VI_U_Buf_Start_Low, (uint8_t) PSU);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1086 setvideoreg(Index_VI_U_Buf_Start_Middle, (uint8_t) (PSU >> 8));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1087 setvideoreg(Index_VI_U_Buf_Start_High, (uint8_t) (PSU >> 16));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1088
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1089 setvideoreg(Index_VI_V_Buf_Start_Low, (uint8_t) PSV);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1090 setvideoreg(Index_VI_V_Buf_Start_Middle, (uint8_t) (PSV >> 8));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1091 setvideoreg(Index_VI_V_Buf_Start_High, (uint8_t) (PSV >> 16));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1092
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1093 /* 310/325 series overflow bits */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1094 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1095 setvideoreg(Index_VI_Disp_UV_Buf_Pitch_High,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1096 (uint8_t) (pitch >> 13));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1097 setvideoreg(Index_VI_U_Buf_Start_Over,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1098 ((uint8_t) (PSU >> 24) & 0x01));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1099 setvideoreg(Index_VI_V_Buf_Start_Over,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1100 ((uint8_t) (PSV >> 24) & 0x01));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1101 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1102 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1103
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1104 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1105 /* Trigger register copy for 310 series */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1106 setvideoreg(Index_VI_Control_Misc3, 1 << index);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1107 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1108
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1109 /* set scale factor */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1110 setvideoreg(Index_VI_Hor_Post_Up_Scale_Low,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1111 (uint8_t) (pOverlay->HUSF));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1112 setvideoreg(Index_VI_Hor_Post_Up_Scale_High,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1113 (uint8_t) ((pOverlay->HUSF) >> 8));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1114 setvideoreg(Index_VI_Ver_Up_Scale_Low, (uint8_t) (pOverlay->VUSF));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1115 setvideoreg(Index_VI_Ver_Up_Scale_High,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1116 (uint8_t) ((pOverlay->VUSF) >> 8));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1117
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1118 setvideoregmask(Index_VI_Scale_Control, (pOverlay->IntBit << 3)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1119 | (pOverlay->wHPre), 0x7f);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1120
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1121 /* set destination window position */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1122 setvideoreg(Index_VI_Win_Hor_Disp_Start_Low, (uint8_t) left);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1123 setvideoreg(Index_VI_Win_Hor_Disp_End_Low, (uint8_t) right);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1124 setvideoreg(Index_VI_Win_Hor_Over, (uint8_t) h_over);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1125
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1126 setvideoreg(Index_VI_Win_Ver_Disp_Start_Low, (uint8_t) top);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1127 setvideoreg(Index_VI_Win_Ver_Disp_End_Low, (uint8_t) bottom);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1128 setvideoreg(Index_VI_Win_Ver_Over, (uint8_t) v_over);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1129
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1130 setvideoregmask(Index_VI_Control_Misc1, pOverlay->bobEnable, 0x1a);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1131
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1132 /* Lock the address registers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1133 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x20);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1134 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1135
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1136
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1137 /* TW: Overlay MUST NOT be switched off while beam is over it */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1138 static void close_overlay(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1139 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1140 uint32_t watchdog;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1141
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1142 if ((sis_displaymode == DISPMODE_SINGLE2) ||
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1143 (sis_displaymode == DISPMODE_MIRROR)) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1144 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1145 setvideoregmask(Index_VI_Control_Misc2, 0x01, 0x01);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1146 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1147 while (vblank_active_CRT2() && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1148 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1149 while ((!vblank_active_CRT2()) && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1150 setvideoregmask(Index_VI_Control_Misc0, 0x00, 0x02);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1151 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1152 while (vblank_active_CRT2() && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1153 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1154 while ((!vblank_active_CRT2()) && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1155 } else if (sis_displaymode == DISPMODE_SINGLE2) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1156 setvideoregmask(Index_VI_Control_Misc2, 0x00, 0x01);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1157 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1158 while (vblank_active_CRT1() && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1159 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1160 while ((!vblank_active_CRT1()) && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1161 setvideoregmask(Index_VI_Control_Misc0, 0x00, 0x02);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1162 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1163 while (vblank_active_CRT1() && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1164 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1165 while ((!vblank_active_CRT1()) && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1166 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1167 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1168 if ((sis_displaymode == DISPMODE_SINGLE1) ||
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1169 (sis_displaymode == DISPMODE_MIRROR)) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1170 setvideoregmask(Index_VI_Control_Misc2, 0x00, 0x01);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1171 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1172 while (vblank_active_CRT1() && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1173 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1174 while ((!vblank_active_CRT1()) && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1175 setvideoregmask(Index_VI_Control_Misc0, 0x00, 0x02);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1176 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1177 while (vblank_active_CRT1() && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1178 watchdog = WATCHDOG_DELAY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1179 while ((!vblank_active_CRT1()) && --watchdog);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1180 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1181 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1182
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1183
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1184 static void
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1185 calc_scale_factor(SISOverlayPtr pOverlay, int index, int iscrt2)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1186 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1187 uint32_t i = 0, mult = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1188 int flag = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1189
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1190 int dstW = pOverlay->dstBox.x2 - pOverlay->dstBox.x1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1191 int dstH = pOverlay->dstBox.y2 - pOverlay->dstBox.y1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1192 int srcW = pOverlay->srcW;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1193 int srcH = pOverlay->srcH;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1194 /* uint16_t LCDheight = pSiS->LCDheight; */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1195 int srcPitch = pOverlay->origPitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1196 int origdstH = dstH;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1197
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1198 /* get rid of warnings for now */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1199 index = index;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1200 iscrt2 = iscrt2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1201
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1202 /* TW: For double scan modes, we need to double the height
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1203 * (Perhaps we also need to scale LVDS, but I'm not sure.)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1204 * On 310/325 series, we need to double the width as well.
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1205 * Interlace mode vice versa.
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1206 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1207 if (sis_vmode & VMODE_DOUBLESCAN) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1208 dstH = origdstH << 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1209 flag = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1210 if (sis_vga_engine == SIS_315_VGA) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1211 dstW <<= 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1212 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1213 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1214 if (sis_vmode & VMODE_INTERLACED) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1215 dstH = origdstH >> 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1216 flag = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1217 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1218
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1219 if (dstW < OVERLAY_MIN_WIDTH)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1220 dstW = OVERLAY_MIN_WIDTH;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1221 if (dstW == srcW) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1222 pOverlay->HUSF = 0x00;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1223 pOverlay->IntBit = 0x05;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1224 pOverlay->wHPre = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1225 } else if (dstW > srcW) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1226 dstW += 2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1227 pOverlay->HUSF = (srcW << 16) / dstW;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1228 pOverlay->IntBit = 0x04;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1229 pOverlay->wHPre = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1230 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1231 int tmpW = dstW;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1232
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1233 /* TW: It seems, the hardware can't scale below factor .125 (=1/8) if the
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1234 pitch isn't a multiple of 256.
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1235 TODO: Test this on the 310/325 series!
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1236 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1237 if ((srcPitch % 256) || (srcPitch < 256)) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1238 if (((dstW * 1000) / srcW) < 125)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1239 dstW = tmpW = ((srcW * 125) / 1000) + 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1240 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1241
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1242 i = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1243 pOverlay->IntBit = 0x01;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1244 while (srcW >= tmpW) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1245 tmpW <<= 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1246 i++;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1247 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1248 pOverlay->wHPre = (uint8_t) (i - 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1249 dstW <<= (i - 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1250 if ((srcW % dstW))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1251 pOverlay->HUSF = ((srcW - dstW) << 16) / dstW;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1252 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1253 pOverlay->HUSF = 0x00;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1254 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1255
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1256 if (dstH < OVERLAY_MIN_HEIGHT)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1257 dstH = OVERLAY_MIN_HEIGHT;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1258 if (dstH == srcH) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1259 pOverlay->VUSF = 0x00;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1260 pOverlay->IntBit |= 0x0A;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1261 } else if (dstH > srcH) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1262 dstH += 0x02;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1263 pOverlay->VUSF = (srcH << 16) / dstH;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1264 pOverlay->IntBit |= 0x08;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1265 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1266 uint32_t realI;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1267
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1268 i = realI = srcH / dstH;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1269 pOverlay->IntBit |= 0x02;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1270
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1271 if (i < 2) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1272 pOverlay->VUSF = ((srcH - dstH) << 16) / dstH;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1273 /* TW: Needed for LCD-scaling modes */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1274 if ((flag) && (mult = (srcH / origdstH)) >= 2)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1275 pOverlay->pitch /= mult;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1276 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1277 if (((srcPitch * i) >> 2) > 0xFFF) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1278 i = (0xFFF * 2 / srcPitch);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1279 pOverlay->VUSF = 0xFFFF;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1280 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1281 dstH = i * dstH;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1282 if (srcH % dstH)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1283 pOverlay->VUSF = ((srcH - dstH) << 16) / dstH;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1284 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1285 pOverlay->VUSF = 0x00;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1286 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1287 /* set video frame buffer offset */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1288 pOverlay->pitch = (uint16_t) (srcPitch * i);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1289 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1290 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1291 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1292
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1293 static void set_line_buf_size(SISOverlayPtr pOverlay)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1294 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1295 uint8_t preHIDF;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1296 uint32_t i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1297 uint32_t line = pOverlay->srcW;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1298
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1299 if ((pOverlay->pixelFormat == IMGFMT_YV12) ||
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1300 (pOverlay->pixelFormat == IMGFMT_I420)) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1301 preHIDF = pOverlay->wHPre & 0x07;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1302 switch (preHIDF) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1303 case 3:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1304 if ((line & 0xffffff00) == line)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1305 i = (line >> 8);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1306 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1307 i = (line >> 8) + 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1308 pOverlay->lineBufSize = (uint8_t) (i * 32 - 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1309 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1310 case 4:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1311 if ((line & 0xfffffe00) == line)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1312 i = (line >> 9);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1313 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1314 i = (line >> 9) + 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1315 pOverlay->lineBufSize = (uint8_t) (i * 64 - 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1316 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1317 case 5:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1318 if ((line & 0xfffffc00) == line)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1319 i = (line >> 10);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1320 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1321 i = (line >> 10) + 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1322 pOverlay->lineBufSize = (uint8_t) (i * 128 - 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1323 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1324 case 6:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1325 if ((line & 0xfffff800) == line)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1326 i = (line >> 11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1327 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1328 i = (line >> 11) + 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1329 pOverlay->lineBufSize = (uint8_t) (i * 256 - 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1330 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1331 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1332 if ((line & 0xffffff80) == line)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1333 i = (line >> 7);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1334 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1335 i = (line >> 7) + 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1336 pOverlay->lineBufSize = (uint8_t) (i * 16 - 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1337 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1338 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1339 } else { /* YUV2, UYVY */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1340 if ((line & 0xffffff8) == line)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1341 i = (line >> 3);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1342 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1343 i = (line >> 3) + 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1344 pOverlay->lineBufSize = (uint8_t) (i - 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1345 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1346 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1347
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1348 static void merge_line_buf(int enable)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1349 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1350 if (enable) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1351 switch (sis_displaymode) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1352 case DISPMODE_SINGLE1:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1353 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1354 /* dual line merge */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1355 setvideoregmask(Index_VI_Control_Misc2, 0x10, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1356 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1357 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1358 setvideoregmask(Index_VI_Control_Misc2, 0x10, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1359 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1360 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1361 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1362 case DISPMODE_SINGLE2:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1363 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1364 /* line merge */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1365 setvideoregmask(Index_VI_Control_Misc2, 0x01, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1366 setvideoregmask(Index_VI_Control_Misc1, 0x04, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1367 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1368 setvideoregmask(Index_VI_Control_Misc2, 0x10, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1369 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1370 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1371 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1372 case DISPMODE_MIRROR:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1373 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1374 /* line merge */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1375 setvideoregmask(Index_VI_Control_Misc2, 0x00, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1376 setvideoregmask(Index_VI_Control_Misc1, 0x04, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1377 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1378 /* line merge */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1379 setvideoregmask(Index_VI_Control_Misc2, 0x01, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1380 setvideoregmask(Index_VI_Control_Misc1, 0x04, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1381 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1382 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1383 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1384 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1385 switch (sis_displaymode) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1386 case DISPMODE_SINGLE1:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1387 setvideoregmask(Index_VI_Control_Misc2, 0x00, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1388 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1389 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1390 case DISPMODE_SINGLE2:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1391 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1392 setvideoregmask(Index_VI_Control_Misc2, 0x01, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1393 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1394 } else {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1395 setvideoregmask(Index_VI_Control_Misc2, 0x00, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1396 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1397 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1398 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1399 case DISPMODE_MIRROR:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1400 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1401 setvideoregmask(Index_VI_Control_Misc2, 0x00, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1402 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1403 if (sis_has_two_overlays) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1404 setvideoregmask(Index_VI_Control_Misc2, 0x01, 0x11);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1405 setvideoregmask(Index_VI_Control_Misc1, 0x00, 0x04);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1406 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1407 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1408 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1409 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1410 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1411
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1412
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1413 static void set_format(SISOverlayPtr pOverlay)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1414 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1415 uint8_t fmt;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1416
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1417 switch (pOverlay->pixelFormat) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1418 case IMGFMT_YV12:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1419 case IMGFMT_I420:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1420 fmt = 0x0c;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1421 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1422 case IMGFMT_YUY2:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1423 fmt = 0x28;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1424 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1425 case IMGFMT_UYVY:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1426 fmt = 0x08;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1427 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1428 case IMGFMT_RGB15: /* D[5:4] : 00 RGB555, 01 RGB 565 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1429 fmt = 0x00;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1430 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1431 case IMGFMT_RGB16:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1432 fmt = 0x10;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1433 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1434 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1435 fmt = 0x00;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1436 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1437 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1438 setvideoregmask(Index_VI_Control_Misc0, fmt, 0x7c);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1439 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1440
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1441 static void set_colorkey(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1442 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1443 uint8_t r, g, b;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1444
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1445 b = (uint8_t) sis_grkey.ckey.blue;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1446 g = (uint8_t) sis_grkey.ckey.green;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1447 r = (uint8_t) sis_grkey.ckey.red;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1448
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1449 /* set color key mode */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1450 setvideoregmask(Index_VI_Key_Overlay_OP,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1451 sis_grkey.ckey.op == CKEY_TRUE ?
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1452 VI_ROP_DestKey : VI_ROP_Always, 0x0F);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1453
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1454 /* set colorkey values */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1455 setvideoreg(Index_VI_Overlay_ColorKey_Blue_Min, (uint8_t) b);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1456 setvideoreg(Index_VI_Overlay_ColorKey_Green_Min, (uint8_t) g);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1457 setvideoreg(Index_VI_Overlay_ColorKey_Red_Min, (uint8_t) r);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1458
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1459 setvideoreg(Index_VI_Overlay_ColorKey_Blue_Max, (uint8_t) b);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1460 setvideoreg(Index_VI_Overlay_ColorKey_Green_Max, (uint8_t) g);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1461 setvideoreg(Index_VI_Overlay_ColorKey_Red_Max, (uint8_t) r);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1462 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1463
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1464 static void set_brightness(uint8_t brightness)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1465 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1466 setvideoreg(Index_VI_Brightness, brightness);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1467 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1468
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1469 static void set_contrast(uint8_t contrast)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1470 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1471 setvideoregmask(Index_VI_Contrast_Enh_Ctrl, contrast, 0x07);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1472 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1473
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1474 /* Next 3 functions are 310/325 series only */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1475
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1476 static void set_saturation(char saturation)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1477 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1478 uint8_t temp = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1479
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1480 if (saturation < 0) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1481 temp |= 0x88;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1482 saturation = -saturation;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1483 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1484 temp |= (saturation & 0x07);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1485 temp |= ((saturation & 0x07) << 4);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1486
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1487 setvideoreg(Index_VI_Saturation, temp);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1488 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1489
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1490 static void set_hue(uint8_t hue)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1491 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1492 setvideoreg(Index_VI_Hue, (hue & 0x08) ? (hue ^ 0x07) : hue);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1493 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1494
22857
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1495 VDXDriver sis_drv = {
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1496 "sis",
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1497 NULL,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1498
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1499 .probe = sis_probe,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1500 .get_caps = sis_get_caps,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1501 .query_fourcc = sis_query_fourcc,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1502 .init = sis_init,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1503 .destroy = sis_destroy,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1504 .config_playback = sis_config_playback,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1505 .playback_on = sis_playback_on,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1506 .playback_off = sis_playback_off,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1507 .frame_sel = sis_frame_select,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1508 .get_eq = sis_get_eq,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1509 .set_eq = sis_set_eq,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1510 .get_gkey = sis_get_gkeys,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1511 .set_gkey = sis_set_gkeys,
77def5093daf switch to new internal vidix API, no more dlopen/dlsym, libvidix is now a fully static library with all drivers built-in
ben
parents: 22850
diff changeset
1512 };