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