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