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