annotate vidix/mach64_vid.c @ 24107:d4adc8503dd5

100l typo: ENTER --> KPENTER
author diego
date Thu, 23 Aug 2007 17:45:54 +0000
parents 2ab3eac7f6da
children b451fd2b2520
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1 /*
23046
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
2 * VIDIX driver for ATI Mach64 and 3DRage chipsets.
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
3 * Copyright (C) 2002 Nick Kurshev
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 * This file is based on sources from
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
22 * GATOS (gatos.sf.net) and X11 (www.xfree86.org)
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
23 */
82216ef041e0 updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents: 22905
diff changeset
24
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
25 #include <errno.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
26 #include <stdio.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
27 #include <stdlib.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
28 #include <string.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
29 #include <math.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
30 #include <inttypes.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
31 #include <fcntl.h>
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
32
22905
f34e5d778267 consistent include paths for config.h et al.
diego
parents: 22901
diff changeset
33 #include "config.h"
f34e5d778267 consistent include paths for config.h et al.
diego
parents: 22901
diff changeset
34 #include "libavutil/common.h"
f34e5d778267 consistent include paths for config.h et al.
diego
parents: 22901
diff changeset
35 #include "mpbswap.h"
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
36 #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
37 #include "vidixlib.h"
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
38 #include "fourcc.h"
22901
a7605669b114 renamed libdha.[hc] to dha.[hc]
ben
parents: 22900
diff changeset
39 #include "dha.h"
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents: 22858
diff changeset
40 #include "pci_ids.h"
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents: 22858
diff changeset
41 #include "pci_names.h"
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
42
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
43 #include "mach64.h"
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
44
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
45 #define UNUSED(x) ((void)(x)) /**< Removes warning about unused arguments */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
46
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
47 static void *mach64_mmio_base = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
48 static void *mach64_mem_base = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
49 static int32_t mach64_overlay_offset = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
50 static uint32_t mach64_ram_size = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
51 static uint32_t mach64_buffer_base[10][3];
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
52 static int num_mach64_buffers=-1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
53 static int supports_planar=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
54 static int supports_lcd_v_stretch=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
55
23053
a74bda857a3c declare variable as static
ben
parents: 23048
diff changeset
56 static pciinfo_t pci_info;
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
57 static int probed = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
58 static int __verbose = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
59
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
60 #define VERBOSE_LEVEL 1
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
61
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
62 typedef struct bes_registers_s
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
63 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
64 /* base address of yuv framebuffer */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
65 uint32_t yuv_base;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
66 uint32_t fourcc;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
67 /* YUV BES registers */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
68 uint32_t reg_load_cntl;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
69 uint32_t scale_inc;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
70 uint32_t y_x_start;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
71 uint32_t y_x_end;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
72 uint32_t vid_buf_pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
73 uint32_t height_width;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
74
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
75 uint32_t scale_cntl;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
76 uint32_t exclusive_horz;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
77 uint32_t auto_flip_cntl;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
78 uint32_t filter_cntl;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
79 uint32_t key_cntl;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
80 uint32_t test;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
81 /* Configurable stuff */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
82
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
83 int brightness;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
84 int saturation;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
85
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
86 int ckey_on;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
87 uint32_t graphics_key_clr;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
88 uint32_t graphics_key_msk;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
89
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
90 int deinterlace_on;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
91 uint32_t deinterlace_pattern;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
92
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
93 } bes_registers_t;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
94
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
95 static bes_registers_t besr;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
96
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
97 typedef struct video_registers_s
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
98 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
99 const char * sname;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
100 uint32_t name;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
101 uint32_t value;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
102 }video_registers_t;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
103
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
104 static bes_registers_t besr;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
105
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
106 /* Graphic keys */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
107 static vidix_grkey_t mach64_grkey;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
108
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
109 #define DECLARE_VREG(name) { #name, name, 0 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
110 static video_registers_t vregs[] =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
111 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
112 DECLARE_VREG(OVERLAY_SCALE_INC),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
113 DECLARE_VREG(OVERLAY_Y_X_START),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
114 DECLARE_VREG(OVERLAY_Y_X_END),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
115 DECLARE_VREG(OVERLAY_SCALE_CNTL),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
116 DECLARE_VREG(OVERLAY_EXCLUSIVE_HORZ),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
117 DECLARE_VREG(OVERLAY_EXCLUSIVE_VERT),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
118 DECLARE_VREG(OVERLAY_TEST),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
119 DECLARE_VREG(SCALER_BUF_PITCH),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
120 DECLARE_VREG(SCALER_HEIGHT_WIDTH),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
121 DECLARE_VREG(SCALER_BUF0_OFFSET),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
122 DECLARE_VREG(SCALER_BUF0_OFFSET_U),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
123 DECLARE_VREG(SCALER_BUF0_OFFSET_V),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
124 DECLARE_VREG(SCALER_BUF1_OFFSET),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
125 DECLARE_VREG(SCALER_BUF1_OFFSET_U),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
126 DECLARE_VREG(SCALER_BUF1_OFFSET_V),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
127 DECLARE_VREG(SCALER_H_COEFF0),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
128 DECLARE_VREG(SCALER_H_COEFF1),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
129 DECLARE_VREG(SCALER_H_COEFF2),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
130 DECLARE_VREG(SCALER_H_COEFF3),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
131 DECLARE_VREG(SCALER_H_COEFF4),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
132 DECLARE_VREG(SCALER_COLOUR_CNTL),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
133 DECLARE_VREG(SCALER_THRESHOLD),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
134 DECLARE_VREG(VIDEO_FORMAT),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
135 DECLARE_VREG(VIDEO_CONFIG),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
136 DECLARE_VREG(VIDEO_SYNC_TEST),
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
137 DECLARE_VREG(VIDEO_SYNC_TEST_B)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
138 };
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
139
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
140 /* have to restore it on exit */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
141 static uint32_t SAVED_OVERLAY_GRAPHICS_KEY_CLR;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
142
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
143 /* VIDIX exports */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
144
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
145 /* MMIO space*/
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
146 #define GETREG(TYPE,PTR,OFFZ) (*((volatile TYPE*)((PTR)+(OFFZ))))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
147 #define SETREG(TYPE,PTR,OFFZ,VAL) (*((volatile TYPE*)((PTR)+(OFFZ))))=VAL
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
148
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
149 #define INREG8(addr) GETREG(uint8_t,(uint8_t *)mach64_mmio_base,((addr)^0x100)<<2)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
150 #define OUTREG8(addr,val) SETREG(uint8_t,(uint8_t *)mach64_mmio_base,((addr)^0x100)<<2,val)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
151
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
152 static inline uint32_t INREG (uint32_t addr) {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
153 uint32_t tmp = GETREG(uint32_t,(uint8_t *)mach64_mmio_base,((addr)^0x100)<<2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
154 return le2me_32(tmp);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
155 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
156 #define OUTREG(addr,val) SETREG(uint32_t,(uint8_t *)mach64_mmio_base,((addr)^0x100)<<2,le2me_32(val))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
157
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
158 #define OUTREGP(addr,val,mask) \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
159 do { \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
160 unsigned int _tmp = INREG(addr); \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
161 _tmp &= (mask); \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
162 _tmp |= (val); \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
163 OUTREG(addr, _tmp); \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
164 } while (0)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
165
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
166 static __inline__ int ATIGetMach64LCDReg(int _Index)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
167 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
168 OUTREG8(LCD_INDEX, _Index);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
169 return INREG(LCD_DATA);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
170 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
171
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
172 static __inline__ uint32_t INPLL(uint32_t addr)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
173 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
174 uint32_t res;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
175 uint32_t in;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
176
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
177 in= INREG(CLOCK_CNTL);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
178 in &= ~((PLL_WR_EN | PLL_ADDR)); //clean some stuff
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
179 OUTREG(CLOCK_CNTL, in | (addr<<10));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
180
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
181 /* read the register value */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
182 res = (INREG(CLOCK_CNTL)>>16)&0xFF;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
183 return res;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
184 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
185
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
186 static __inline__ void OUTPLL(uint32_t addr,uint32_t val)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
187 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
188 //FIXME buggy but its not used
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
189 /* write addr byte */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
190 OUTREG8(CLOCK_CNTL + 1, (addr << 2) | PLL_WR_EN);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
191 /* write the register value */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
192 OUTREG(CLOCK_CNTL + 2, val);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
193 OUTREG8(CLOCK_CNTL + 1, (addr << 2) & ~PLL_WR_EN);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
194 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
195
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
196 #define OUTPLLP(addr,val,mask) \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
197 do { \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
198 unsigned int _tmp = INPLL(addr); \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
199 _tmp &= (mask); \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
200 _tmp |= (val); \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
201 OUTPLL(addr, _tmp); \
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
202 } while (0)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
203
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
204 static void mach64_fifo_wait(unsigned n)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
205 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
206 while ((INREG(FIFO_STAT) & 0xffff) > ((uint32_t)(0x8000 >> n)));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
207 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
208
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
209 static void mach64_wait_for_idle( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
210 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
211 mach64_fifo_wait(16);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
212 while ((INREG(GUI_STAT) & 1)!= 0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
213 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
214
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
215 static void mach64_wait_vsync( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
216 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
217 int i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
218
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
219 for(i=0; i<2000000; i++)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
220 if( (INREG(CRTC_INT_CNTL)&CRTC_VBLANK)==0 ) break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
221 for(i=0; i<2000000; i++)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
222 if( (INREG(CRTC_INT_CNTL)&CRTC_VBLANK) ) break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
223
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
224 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
225
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
226 static vidix_capability_t mach64_cap =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
227 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
228 "BES driver for Mach64/3DRage cards",
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
229 "Nick Kurshev and Michael Niedermayer",
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
230 TYPE_OUTPUT,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
231 { 0, 0, 0, 0 },
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
232 2048,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
233 2048,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
234 4,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
235 4,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
236 -1,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
237 FLAG_UPSCALER|FLAG_DOWNSCALER,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
238 VENDOR_ATI,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
239 -1,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
240 { 0, 0, 0, 0 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
241 };
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
242
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
243 static uint32_t mach64_vid_get_dbpp( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
244 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
245 uint32_t dbpp,retval;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
246 dbpp = (INREG(CRTC_GEN_CNTL)>>8)& 0x7;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
247 switch(dbpp)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
248 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
249 case 1: retval = 4; break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
250 case 2: retval = 8; break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
251 case 3: retval = 15; break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
252 case 4: retval = 16; break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
253 case 5: retval = 24; break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
254 default: retval=32; break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
255 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
256 return retval;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
257 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
258
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
259 static int mach64_is_dbl_scan( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
260 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
261 return INREG(CRTC_GEN_CNTL) & CRTC_DBL_SCAN_EN;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
262 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
263
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
264 static int mach64_is_interlace( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
265 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
266 return INREG(CRTC_GEN_CNTL) & CRTC_INTERLACE_EN;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
267 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
268
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
269 static uint32_t mach64_get_xres( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
270 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
271 /* FIXME: currently we extract that from CRTC!!!*/
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
272 uint32_t xres,h_total;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
273 h_total = INREG(CRTC_H_TOTAL_DISP);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
274 xres = (h_total >> 16) & 0xffff;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
275 return (xres + 1)*8;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
276 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
277
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
278 static uint32_t mach64_get_yres( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
279 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
280 /* FIXME: currently we extract that from CRTC!!!*/
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
281 uint32_t yres,v_total;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
282 v_total = INREG(CRTC_V_TOTAL_DISP);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
283 yres = (v_total >> 16) & 0xffff;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
284 return yres + 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
285 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
286
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
287 // returns the verical stretch factor in 16.16
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
288 static int mach64_get_vert_stretch(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
289 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
290 int lcd_index;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
291 int vert_stretching;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
292 int ext_vert_stretch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
293 int ret;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
294 int yres= mach64_get_yres();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
295
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
296 if(!supports_lcd_v_stretch){
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
297 if(__verbose>0) printf("[mach64] vertical stretching not supported\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
298 return 1<<16;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
299 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
300
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
301 lcd_index= INREG(LCD_INDEX);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
302
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
303 vert_stretching= ATIGetMach64LCDReg(LCD_VERT_STRETCHING);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
304 if(!(vert_stretching&VERT_STRETCH_EN)) ret= 1<<16;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
305 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
306 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
307 int panel_size;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
308
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
309 ext_vert_stretch= ATIGetMach64LCDReg(LCD_EXT_VERT_STRETCH);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
310 panel_size= (ext_vert_stretch&VERT_PANEL_SIZE)>>11;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
311 panel_size++;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
312
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
313 ret= ((yres<<16) + (panel_size>>1))/panel_size;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
314 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
315
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
316 // lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
317
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
318 OUTREG(LCD_INDEX, lcd_index);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
319
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
320 if(__verbose>0) printf("[mach64] vertical stretching factor= %d\n", ret);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
321
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
322 return ret;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
323 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
324
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
325 static void mach64_vid_make_default(void)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
326 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
327 mach64_fifo_wait(5);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
328 OUTREG(SCALER_COLOUR_CNTL,0x00101000);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
329
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
330 besr.ckey_on=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
331 besr.graphics_key_msk=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
332 besr.graphics_key_clr=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
333
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
334 OUTREG(OVERLAY_GRAPHICS_KEY_MSK, besr.graphics_key_msk);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
335 OUTREG(OVERLAY_GRAPHICS_KEY_CLR, besr.graphics_key_clr);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
336 OUTREG(OVERLAY_KEY_CNTL,VIDEO_KEY_FN_TRUE|GRAPHIC_KEY_FN_EQ|CMP_MIX_AND);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
337
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
338 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
339
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
340 static void mach64_vid_dump_regs( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
341 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
342 size_t i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
343 printf("[mach64] *** Begin of DRIVER variables dump ***\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
344 printf("[mach64] mach64_mmio_base=%p\n",mach64_mmio_base);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
345 printf("[mach64] mach64_mem_base=%p\n",mach64_mem_base);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
346 printf("[mach64] mach64_overlay_off=%08X\n",mach64_overlay_offset);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
347 printf("[mach64] mach64_ram_size=%08X\n",mach64_ram_size);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
348 printf("[mach64] video mode: %ux%u@%u\n",mach64_get_xres(),mach64_get_yres(),mach64_vid_get_dbpp());
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
349 printf("[mach64] *** Begin of OV0 registers dump ***\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
350 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
351 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
352 mach64_wait_for_idle();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
353 printf("[mach64] %s = %08X\n",vregs[i].sname,INREG(vregs[i].name));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
354 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
355 printf("[mach64] *** End of OV0 registers dump ***\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
356 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
357
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
358
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
359 static unsigned short ati_card_ids[] =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
360 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
361 DEVICE_ATI_215CT_MACH64_CT,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
362 DEVICE_ATI_210888CX_MACH64_CX,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
363 DEVICE_ATI_210888ET_MACH64_ET,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
364 DEVICE_ATI_MACH64_VT,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
365 DEVICE_ATI_210888GX_MACH64_GX,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
366 DEVICE_ATI_264LT_MACH64_LT,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
367 DEVICE_ATI_264VT_MACH64_VT,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
368 DEVICE_ATI_264VT3_MACH64_VT3,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
369 DEVICE_ATI_264VT4_MACH64_VT4,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
370 /**/
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
371 DEVICE_ATI_3D_RAGE_PRO,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
372 DEVICE_ATI_3D_RAGE_PRO2,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
373 DEVICE_ATI_3D_RAGE_PRO3,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
374 DEVICE_ATI_3D_RAGE_PRO4,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
375 DEVICE_ATI_RAGE_XC,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
376 DEVICE_ATI_RAGE_XL_AGP,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
377 DEVICE_ATI_RAGE_XC_AGP,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
378 DEVICE_ATI_RAGE_XL,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
379 DEVICE_ATI_3D_RAGE_PRO5,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
380 DEVICE_ATI_3D_RAGE_PRO6,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
381 DEVICE_ATI_RAGE_XL2,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
382 DEVICE_ATI_RAGE_XC2,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
383 DEVICE_ATI_3D_RAGE_I_II,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
384 DEVICE_ATI_3D_RAGE_II,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
385 DEVICE_ATI_3D_RAGE_IIC,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
386 DEVICE_ATI_3D_RAGE_IIC2,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
387 DEVICE_ATI_3D_RAGE_IIC3,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
388 DEVICE_ATI_3D_RAGE_IIC4,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
389 DEVICE_ATI_3D_RAGE_LT,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
390 DEVICE_ATI_3D_RAGE_LT2,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
391 DEVICE_ATI_3D_RAGE_LT_G,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
392 DEVICE_ATI_3D_RAGE_LT3,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
393 DEVICE_ATI_RAGE_MOBILITY_P_M,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
394 DEVICE_ATI_RAGE_MOBILITY_L,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
395 DEVICE_ATI_3D_RAGE_LT4,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
396 DEVICE_ATI_3D_RAGE_LT5,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
397 DEVICE_ATI_RAGE_MOBILITY_P_M2,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
398 DEVICE_ATI_RAGE_MOBILITY_L2
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
399 };
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
400
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
401 static int find_chip(unsigned chip_id)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
402 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
403 unsigned i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
404 for(i = 0;i < sizeof(ati_card_ids)/sizeof(unsigned short);i++)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
405 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
406 if(chip_id == ati_card_ids[i]) return i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
407 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
408 return -1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
409 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
410
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
411 static int mach64_probe(int verbose,int force)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
412 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
413 pciinfo_t lst[MAX_PCI_DEVICES];
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
414 unsigned i,num_pci;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
415 int err;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
416 __verbose = verbose;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
417 err = pci_scan(lst,&num_pci);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
418 if(err)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
419 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
420 printf("[mach64] Error occurred during pci scan: %s\n",strerror(err));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
421 return err;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
422 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
423 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
424 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
425 err = ENXIO;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
426 for(i=0;i<num_pci;i++)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
427 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
428 if(lst[i].vendor == VENDOR_ATI)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
429 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
430 int idx;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
431 const char *dname;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
432 idx = find_chip(lst[i].device);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
433 if(idx == -1 && force == PROBE_NORMAL) continue;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
434 dname = pci_device_name(VENDOR_ATI,lst[i].device);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
435 dname = dname ? dname : "Unknown chip";
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
436 printf("[mach64] Found chip: %s\n",dname);
23167
2ab3eac7f6da synced with upstream vidix, prevented some drivers to work on some configs/archs
ben
parents: 23060
diff changeset
437 #if 0
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
438 if ((lst[i].command & PCI_COMMAND_IO) == 0)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
439 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
440 printf("[mach64] Device is disabled, ignoring\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
441 continue;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
442 }
23167
2ab3eac7f6da synced with upstream vidix, prevented some drivers to work on some configs/archs
ben
parents: 23060
diff changeset
443 #endif
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
444 if(force > PROBE_NORMAL)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
445 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
446 printf("[mach64] Driver was forced. Was found %sknown chip\n",idx == -1 ? "un" : "");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
447 if(idx == -1)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
448 printf("[mach64] Assuming it as Mach64\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
449 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
450 mach64_cap.device_id = lst[i].device;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
451 err = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
452 memcpy(&pci_info,&lst[i],sizeof(pciinfo_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
453 probed=1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
454 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
455 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
456 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
457 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
458 if(err && verbose) printf("[mach64] Can't find chip\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
459 return err;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
460 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
461
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
462 static void reset_regs( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
463 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
464 size_t i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
465 for(i=0;i<sizeof(vregs)/sizeof(video_registers_t);i++)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
466 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
467 mach64_fifo_wait(2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
468 OUTREG(vregs[i].name,0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
469 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
470 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
471
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
472
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
473 static int mach64_init(void)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
474 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
475 int err;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
476 if(!probed)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
477 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
478 printf("[mach64] Driver was not probed but is being initializing\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
479 return EINTR;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
480 }
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
481 if(__verbose>0) printf("[mach64] version %d\n", VIDIX_VERSION);
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
482
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
483 if((mach64_mmio_base = map_phys_mem(pci_info.base2,0x1000))==(void *)-1) return ENOMEM;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
484 mach64_wait_for_idle();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
485 mach64_ram_size = INREG(MEM_CNTL) & CTL_MEM_SIZEB;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
486 if (mach64_ram_size < 8) mach64_ram_size = (mach64_ram_size + 1) * 512;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
487 else if (mach64_ram_size < 12) mach64_ram_size = (mach64_ram_size - 3) * 1024;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
488 else mach64_ram_size = (mach64_ram_size - 7) * 2048;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
489 mach64_ram_size *= 0x400; /* KB -> bytes */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
490 if((mach64_mem_base = map_phys_mem(pci_info.base0,mach64_ram_size))==(void *)-1) return ENOMEM;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
491 memset(&besr,0,sizeof(bes_registers_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
492 printf("[mach64] Video memory = %uMb\n",mach64_ram_size/0x100000);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
493 err = mtrr_set_type(pci_info.base0,mach64_ram_size,MTRR_TYPE_WRCOMB);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
494 if(!err) printf("[mach64] Set write-combining type of video memory\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
495
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
496 /* save this */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
497 mach64_wait_for_idle();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
498 SAVED_OVERLAY_GRAPHICS_KEY_CLR = INREG(OVERLAY_GRAPHICS_KEY_CLR);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
499
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
500 /* check if planar formats are supported */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
501 supports_planar=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
502 mach64_wait_for_idle();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
503 mach64_fifo_wait(2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
504 if(INREG(SCALER_BUF0_OFFSET_U)) supports_planar=1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
505 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
506 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
507 OUTREG(SCALER_BUF0_OFFSET_U, -1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
508
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
509 mach64_wait_vsync();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
510 mach64_wait_for_idle();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
511 mach64_fifo_wait(2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
512
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
513 if(INREG(SCALER_BUF0_OFFSET_U)) supports_planar=1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
514 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
515 if(supports_planar) printf("[mach64] Planar YUV formats are supported :)\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
516 else printf("[mach64] Planar YUV formats are not supported :(\n");
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
517
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
518 if( mach64_cap.device_id==DEVICE_ATI_RAGE_MOBILITY_P_M
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
519 || mach64_cap.device_id==DEVICE_ATI_RAGE_MOBILITY_P_M2
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
520 || mach64_cap.device_id==DEVICE_ATI_RAGE_MOBILITY_L
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
521 || mach64_cap.device_id==DEVICE_ATI_RAGE_MOBILITY_L2)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
522 supports_lcd_v_stretch=1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
523 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
524 supports_lcd_v_stretch=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
525
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
526 reset_regs();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
527 mach64_vid_make_default();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
528
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
529 if(__verbose > VERBOSE_LEVEL) mach64_vid_dump_regs();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
530 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
531 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
532
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
533 static void mach64_destroy(void)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
534 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
535 /*restore this*/
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
536 mach64_wait_for_idle();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
537 OUTREG(OVERLAY_GRAPHICS_KEY_CLR,SAVED_OVERLAY_GRAPHICS_KEY_CLR);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
538
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
539 unmap_phys_mem(mach64_mem_base,mach64_ram_size);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
540 unmap_phys_mem(mach64_mmio_base,0x1000);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
541 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
542
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
543 static int mach64_get_caps(vidix_capability_t *to)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
544 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
545 memcpy(to, &mach64_cap, sizeof(vidix_capability_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
546 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
547 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
548
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
549 static unsigned mach64_query_pitch(unsigned fourcc,const vidix_yuv_t *spitch)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
550 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
551 unsigned pitch,spy,spv,spu;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
552 spy = spv = spu = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
553 switch(spitch->y)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
554 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
555 case 16:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
556 case 32:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
557 case 64:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
558 case 128:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
559 case 256: spy = spitch->y; break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
560 default: break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
561 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
562 switch(spitch->u)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
563 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
564 case 16:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
565 case 32:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
566 case 64:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
567 case 128:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
568 case 256: spu = spitch->u; break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
569 default: break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
570 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
571 switch(spitch->v)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
572 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
573 case 16:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
574 case 32:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
575 case 64:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
576 case 128:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
577 case 256: spv = spitch->v; break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
578 default: break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
579 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
580 switch(fourcc)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
581 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
582 /* 4:2:0 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
583 case IMGFMT_IYUV:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
584 case IMGFMT_YV12:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
585 case IMGFMT_I420:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
586 if(spy > 16 && spu == spy/2 && spv == spy/2) pitch = spy;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
587 else pitch = 32;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
588 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
589 case IMGFMT_YVU9:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
590 if(spy > 32 && spu == spy/4 && spv == spy/4) pitch = spy;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
591 else pitch = 64;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
592 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
593 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
594 if(spy >= 16) pitch = spy;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
595 else pitch = 16;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
596 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
597 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
598 return pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
599 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
600
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
601 static void mach64_compute_framesize(vidix_playback_t *info)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
602 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
603 unsigned pitch,awidth;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
604 pitch = mach64_query_pitch(info->fourcc,&info->src.pitch);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
605 switch(info->fourcc)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
606 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
607 case IMGFMT_I420:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
608 case IMGFMT_YV12:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
609 case IMGFMT_IYUV:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
610 awidth = (info->src.w + (pitch-1)) & ~(pitch-1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
611 info->frame_size = awidth*(info->src.h+info->src.h/2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
612 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
613 case IMGFMT_YVU9:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
614 awidth = (info->src.w + (pitch-1)) & ~(pitch-1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
615 info->frame_size = awidth*(info->src.h+info->src.h/8);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
616 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
617 // case IMGFMT_RGB32:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
618 case IMGFMT_BGR32:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
619 awidth = (info->src.w*4 + (pitch-1)) & ~(pitch-1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
620 info->frame_size = (awidth*info->src.h);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
621 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
622 /* YUY2 YVYU, RGB15, RGB16 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
623 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
624 awidth = (info->src.w*2 + (pitch-1)) & ~(pitch-1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
625 info->frame_size = (awidth*info->src.h);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
626 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
627 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
628 info->frame_size+=256; // so we have some space for alignment & such
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
629 info->frame_size&=~16;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
630 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
631
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
632 static void mach64_vid_stop_video( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
633 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
634 mach64_fifo_wait(14);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
635 OUTREG(OVERLAY_SCALE_CNTL, 0x80000000);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
636 OUTREG(OVERLAY_EXCLUSIVE_HORZ, 0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
637 OUTREG(OVERLAY_EXCLUSIVE_VERT, 0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
638 OUTREG(SCALER_H_COEFF0, 0x00002000);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
639 OUTREG(SCALER_H_COEFF1, 0x0D06200D);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
640 OUTREG(SCALER_H_COEFF2, 0x0D0A1C0D);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
641 OUTREG(SCALER_H_COEFF3, 0x0C0E1A0C);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
642 OUTREG(SCALER_H_COEFF4, 0x0C14140C);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
643 OUTREG(VIDEO_FORMAT, 0xB000B);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
644 OUTREG(OVERLAY_TEST, 0x0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
645 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
646
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
647 static void mach64_vid_display_video( void )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
648 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
649 uint32_t vf;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
650 mach64_fifo_wait(14);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
651
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
652 OUTREG(OVERLAY_Y_X_START, besr.y_x_start);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
653 OUTREG(OVERLAY_Y_X_END, besr.y_x_end);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
654 OUTREG(OVERLAY_SCALE_INC, besr.scale_inc);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
655 OUTREG(SCALER_BUF_PITCH, besr.vid_buf_pitch);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
656 OUTREG(SCALER_HEIGHT_WIDTH, besr.height_width);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
657 OUTREG(SCALER_BUF0_OFFSET, mach64_buffer_base[0][0]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
658 OUTREG(SCALER_BUF0_OFFSET_U, mach64_buffer_base[0][1]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
659 OUTREG(SCALER_BUF0_OFFSET_V, mach64_buffer_base[0][2]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
660 OUTREG(SCALER_BUF1_OFFSET, mach64_buffer_base[0][0]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
661 OUTREG(SCALER_BUF1_OFFSET_U, mach64_buffer_base[0][1]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
662 OUTREG(SCALER_BUF1_OFFSET_V, mach64_buffer_base[0][2]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
663 mach64_wait_vsync();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
664
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
665 mach64_fifo_wait(4);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
666 OUTREG(OVERLAY_SCALE_CNTL, 0xC4000003);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
667 // OVERLAY_SCALE_CNTL bits & what they seem to affect
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
668 // bit 0 no effect
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
669 // bit 1 yuv2rgb coeff related
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
670 // bit 2 horizontal interpolation if 0
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
671 // bit 3 vertical interpolation if 0
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
672 // bit 4 chroma encoding (0-> 128=neutral / 1-> 0->neutral)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
673 // bit 5-6 gamma correction
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
674 // bit 7 nothing visible if set
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
675 // bit 8-27 no effect
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
676 // bit 28-31 nothing interresting just crashed my system when i played with them :(
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
677
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
678 mach64_wait_for_idle();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
679 vf = INREG(VIDEO_FORMAT);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
680
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
681 // Bits 16-19 seem to select the format
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
682 // 0x0 dunno behaves strange
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
683 // 0x1 dunno behaves strange
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
684 // 0x2 dunno behaves strange
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
685 // 0x3 BGR15
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
686 // 0x4 BGR16
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
687 // 0x5 BGR16 (hmm, that need investigation, 2 BGR16 formats, i guess 1 will have only 5bits for green)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
688 // 0x6 BGR32
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
689 // 0x7 BGR32 with somehow mixed even / odd pixels ?
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
690 // 0x8 YYYYUVUV
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
691 // 0x9 YVU9
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
692 // 0xA YV12
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
693 // 0xB YUY2
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
694 // 0xC UYVY
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
695 // 0xD UYVY (no difference is visible if i switch between C/D for every even/odd frame)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
696 // 0xE dunno behaves strange
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
697 // 0xF dunno behaves strange
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
698 // Bit 28 all values are assumed to be 7 bit with chroma=64 for black (tested with YV12 & YUY2)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
699 // the remaining bits seem to have no effect
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
700
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
701
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
702 switch(besr.fourcc)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
703 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
704 /* BGR formats */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
705 case IMGFMT_BGR15: OUTREG(VIDEO_FORMAT, 0x00030000); break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
706 case IMGFMT_BGR16: OUTREG(VIDEO_FORMAT, 0x00040000); break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
707 case IMGFMT_BGR32: OUTREG(VIDEO_FORMAT, 0x00060000); break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
708 /* 4:2:0 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
709 case IMGFMT_IYUV:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
710 case IMGFMT_I420:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
711 case IMGFMT_YV12: OUTREG(VIDEO_FORMAT, 0x000A0000); break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
712
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
713 case IMGFMT_YVU9: OUTREG(VIDEO_FORMAT, 0x00090000); break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
714 /* 4:2:2 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
715 case IMGFMT_YVYU:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
716 case IMGFMT_UYVY: OUTREG(VIDEO_FORMAT, 0x000C0000); break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
717 case IMGFMT_YUY2:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
718 default: OUTREG(VIDEO_FORMAT, 0x000B0000); break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
719 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
720 if(__verbose > VERBOSE_LEVEL) mach64_vid_dump_regs();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
721 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
722
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
723 static int mach64_vid_init_video( vidix_playback_t *config )
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
724 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
725 uint32_t src_w,src_h,dest_w,dest_h,pitch,h_inc,v_inc,left,leftUV,top,ecp,y_pos;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
726 int is_420,best_pitch,mpitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
727 int src_offset_y, src_offset_u, src_offset_v;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
728 unsigned int i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
729
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
730 mach64_vid_stop_video();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
731 /* warning, if left or top are != 0 this will fail, as the framesize is too small then */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
732 left = config->src.x;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
733 top = config->src.y;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
734 src_h = config->src.h;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
735 src_w = config->src.w;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
736 is_420 = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
737 if(config->fourcc == IMGFMT_YV12 ||
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
738 config->fourcc == IMGFMT_I420 ||
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
739 config->fourcc == IMGFMT_IYUV) is_420 = 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
740 best_pitch = mach64_query_pitch(config->fourcc,&config->src.pitch);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
741 mpitch = best_pitch-1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
742 switch(config->fourcc)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
743 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
744 case IMGFMT_YVU9:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
745 /* 4:2:0 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
746 case IMGFMT_IYUV:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
747 case IMGFMT_YV12:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
748 case IMGFMT_I420: pitch = (src_w + mpitch) & ~mpitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
749 config->dest.pitch.y =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
750 config->dest.pitch.u =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
751 config->dest.pitch.v = best_pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
752 besr.vid_buf_pitch= pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
753 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
754 /* RGB 4:4:4:4 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
755 case IMGFMT_RGB32:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
756 case IMGFMT_BGR32: pitch = (src_w*4 + mpitch) & ~mpitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
757 config->dest.pitch.y =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
758 config->dest.pitch.u =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
759 config->dest.pitch.v = best_pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
760 besr.vid_buf_pitch= pitch>>2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
761 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
762 /* 4:2:2 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
763 default: /* RGB15, RGB16, YVYU, UYVY, YUY2 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
764 pitch = ((src_w*2) + mpitch) & ~mpitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
765 config->dest.pitch.y =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
766 config->dest.pitch.u =
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
767 config->dest.pitch.v = best_pitch;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
768 besr.vid_buf_pitch= pitch>>1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
769 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
770 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
771 dest_w = config->dest.w;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
772 dest_h = config->dest.h;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
773 besr.fourcc = config->fourcc;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
774 ecp = (INPLL(PLL_VCLK_CNTL) & PLL_ECP_DIV) >> 4;
23048
7973a6935234 removed useless code from vidix drivers
ben
parents: 23046
diff changeset
775
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
776 if(__verbose>0) printf("[mach64] ecp: %d\n", ecp);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
777 v_inc = src_h * mach64_get_vert_stretch();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
778
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
779 if(mach64_is_interlace()) v_inc<<=1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
780 if(mach64_is_dbl_scan() ) v_inc>>=1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
781 v_inc>>=4; // convert 16.16 -> 20.12
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
782 v_inc/= dest_h;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
783
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
784 h_inc = (src_w << (12+ecp)) / dest_w;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
785 /* keep everything in 16.16 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
786 config->offsets[0] = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
787 for(i=1; i<config->num_frames; i++)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
788 config->offsets[i] = config->offsets[i-1] + config->frame_size;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
789
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
790 /*FIXME the left / top stuff is broken (= zoom a src rectangle from a larger one)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
791 1. the framesize isn't known as the outer src rectangle dimensions aren't known
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
792 2. the mach64 needs aligned addresses so it can't work anyway
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
793 -> so we could shift the outer buffer to compensate that but that would mean
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
794 alignment problems for the code which writes into it
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
795 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
796
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
797 if(is_420)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
798 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
799 config->offset.y= 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
800 config->offset.u= (pitch*src_h + 15)&~15;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
801 config->offset.v= (config->offset.u + (pitch*src_h>>2) + 15)&~15;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
802
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
803 if(besr.fourcc == IMGFMT_I420 || besr.fourcc == IMGFMT_IYUV)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
804 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
805 uint32_t tmp;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
806 tmp = config->offset.u;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
807 config->offset.u = config->offset.v;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
808 config->offset.v = tmp;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
809 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
810
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
811 src_offset_y= config->offset.y + top*pitch + left;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
812 src_offset_u= config->offset.u + (top*pitch>>2) + (left>>1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
813 src_offset_v= config->offset.v + (top*pitch>>2) + (left>>1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
814 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
815 else if(besr.fourcc == IMGFMT_YVU9)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
816 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
817 config->offset.y= 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
818 config->offset.u= (pitch*src_h + 15)&~15;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
819 config->offset.v= (config->offset.u + (pitch*src_h>>4) + 15)&~15;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
820
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
821 src_offset_y= config->offset.y + top*pitch + left;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
822 src_offset_u= config->offset.u + (top*pitch>>4) + (left>>1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
823 src_offset_v= config->offset.v + (top*pitch>>4) + (left>>1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
824 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
825 else if(besr.fourcc == IMGFMT_BGR32)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
826 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
827 config->offset.y = config->offset.u = config->offset.v = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
828 src_offset_y= src_offset_u= src_offset_v= top*pitch + (left << 2);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
829 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
830 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
831 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
832 config->offset.y = config->offset.u = config->offset.v = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
833 src_offset_y= src_offset_u= src_offset_v= top*pitch + (left << 1);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
834 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
835
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
836 num_mach64_buffers= config->num_frames;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
837 for(i=0; i<config->num_frames; i++)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
838 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
839 mach64_buffer_base[i][0]= (mach64_overlay_offset + config->offsets[i] + src_offset_y)&~15;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
840 mach64_buffer_base[i][1]= (mach64_overlay_offset + config->offsets[i] + src_offset_u)&~15;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
841 mach64_buffer_base[i][2]= (mach64_overlay_offset + config->offsets[i] + src_offset_v)&~15;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
842 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
843
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
844 leftUV = (left >> 17) & 15;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
845 left = (left >> 16) & 15;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
846 besr.scale_inc = ( h_inc << 16 ) | v_inc;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
847 y_pos = config->dest.y;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
848 if(mach64_is_dbl_scan()) y_pos*=2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
849 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
850 if(mach64_is_interlace()) y_pos/=2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
851 besr.y_x_start = y_pos | (config->dest.x << 16);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
852 y_pos =config->dest.y + dest_h;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
853 if(mach64_is_dbl_scan()) y_pos*=2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
854 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
855 if(mach64_is_interlace()) y_pos/=2;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
856 besr.y_x_end = y_pos | ((config->dest.x + dest_w) << 16);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
857 besr.height_width = ((src_w - left)<<16) | (src_h - top);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
858
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
859 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
860 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
861
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
862 static int is_supported_fourcc(uint32_t fourcc)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
863 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
864 switch(fourcc)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
865 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
866 case IMGFMT_YV12:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
867 case IMGFMT_I420:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
868 case IMGFMT_YVU9:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
869 case IMGFMT_IYUV:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
870 return supports_planar;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
871 case IMGFMT_YUY2:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
872 case IMGFMT_UYVY:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
873 case IMGFMT_BGR15:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
874 case IMGFMT_BGR16:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
875 case IMGFMT_BGR32:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
876 return 1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
877 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
878 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
879 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
880 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
881
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
882 static int mach64_query_fourcc(vidix_fourcc_t *to)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
883 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
884 if(is_supported_fourcc(to->fourcc))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
885 {
23060
91ad6d4d6a54 simplified depth definition
ben
parents: 23053
diff changeset
886 to->depth = VID_DEPTH_ALL;
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
887 to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
888 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
889 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
890 else to->depth = to->flags = 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
891 return ENOSYS;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
892 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
893
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
894 static int mach64_config_playback(vidix_playback_t *info)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
895 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
896 if(!is_supported_fourcc(info->fourcc)) return ENOSYS;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
897
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
898 mach64_compute_framesize(info);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
899
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
900 if(info->num_frames>4) info->num_frames=4;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
901 for(;info->num_frames>0; info->num_frames--)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
902 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
903 mach64_overlay_offset = mach64_ram_size - info->frame_size*info->num_frames;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
904 mach64_overlay_offset &= 0xffff0000;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
905 if(mach64_overlay_offset>0) break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
906 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
907 if(info->num_frames <= 0) return EINVAL;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
908
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
909 info->dga_addr = (char *)mach64_mem_base + mach64_overlay_offset;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
910 mach64_vid_init_video(info);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
911 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
912 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
913
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
914 static int mach64_playback_on(void)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
915 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
916 mach64_vid_display_video();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
917 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
918 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
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 mach64_playback_off(void)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
921 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
922 mach64_vid_stop_video();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
923 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
924 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
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 mach64_frame_sel(unsigned int frame)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
927 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
928 uint32_t off[6];
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
929 int i;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
930 int last_frame= (frame-1+num_mach64_buffers) % num_mach64_buffers;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
931 //printf("Selecting frame %d\n", frame);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
932 /*
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
933 buf3-5 always should point onto second buffer for better
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
934 deinterlacing and TV-in
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
935 */
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
936 if(num_mach64_buffers==1) return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
937
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
938 for(i=0; i<3; i++)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
939 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
940 off[i] = mach64_buffer_base[frame][i];
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
941 off[i+3]= mach64_buffer_base[last_frame][i];
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
942 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
943
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
944 mach64_wait_for_idle();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
945 mach64_fifo_wait(7);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
946
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
947 OUTREG(SCALER_BUF0_OFFSET, off[0]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
948 OUTREG(SCALER_BUF0_OFFSET_U, off[1]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
949 OUTREG(SCALER_BUF0_OFFSET_V, off[2]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
950 OUTREG(SCALER_BUF1_OFFSET, off[3]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
951 OUTREG(SCALER_BUF1_OFFSET_U, off[4]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
952 OUTREG(SCALER_BUF1_OFFSET_V, off[5]);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
953 if(num_mach64_buffers==2) mach64_wait_vsync(); //only wait for vsync if we do double buffering
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
954
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
955 if(__verbose > VERBOSE_LEVEL) mach64_vid_dump_regs();
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
956 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
957 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
958
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
959 static vidix_video_eq_t equal =
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
960 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
961 VEQ_CAP_BRIGHTNESS | VEQ_CAP_SATURATION
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
962 ,
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
963 0, 0, 0, 0, 0, 0, 0, 0 };
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
964
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
965 static int mach64_get_eq( vidix_video_eq_t * eq)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
966 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
967 memcpy(eq,&equal,sizeof(vidix_video_eq_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
968 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
969 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
970
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
971 static int mach64_set_eq( const vidix_video_eq_t * eq)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
972 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
973 int br,sat;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
974 if(eq->cap & VEQ_CAP_BRIGHTNESS) equal.brightness = eq->brightness;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
975 if(eq->cap & VEQ_CAP_CONTRAST) equal.contrast = eq->contrast;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
976 if(eq->cap & VEQ_CAP_SATURATION) equal.saturation = eq->saturation;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
977 if(eq->cap & VEQ_CAP_HUE) equal.hue = eq->hue;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
978 if(eq->cap & VEQ_CAP_RGB_INTENSITY)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
979 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
980 equal.red_intensity = eq->red_intensity;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
981 equal.green_intensity = eq->green_intensity;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
982 equal.blue_intensity = eq->blue_intensity;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
983 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
984 equal.flags = eq->flags;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
985 br = equal.brightness * 64 / 1000;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
986 if(br < -64) br = -64; if(br > 63) br = 63;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
987 sat = (equal.saturation + 1000) * 16 / 1000;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
988 if(sat < 0) sat = 0; if(sat > 31) sat = 31;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
989 OUTREG(SCALER_COLOUR_CNTL, (br & 0x7f) | (sat << 8) | (sat << 16));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
990 return 0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
991 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
992
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
993 static int mach64_get_gkeys(vidix_grkey_t *grkey)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
994 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
995 memcpy(grkey, &mach64_grkey, sizeof(vidix_grkey_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
996 return(0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
997 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
998
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
999 static int mach64_set_gkeys(const vidix_grkey_t *grkey)
22850
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1000 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1001 memcpy(&mach64_grkey, grkey, sizeof(vidix_grkey_t));
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1002
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1003 if(mach64_grkey.ckey.op == CKEY_TRUE)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1004 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1005 besr.ckey_on=1;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1006
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1007 switch(mach64_vid_get_dbpp())
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1008 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1009 case 15:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1010 besr.graphics_key_msk=0x7FFF;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1011 besr.graphics_key_clr=
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1012 ((mach64_grkey.ckey.blue &0xF8)>>3)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1013 | ((mach64_grkey.ckey.green&0xF8)<<2)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1014 | ((mach64_grkey.ckey.red &0xF8)<<7);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1015 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1016 case 16:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1017 besr.graphics_key_msk=0xFFFF;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1018 besr.graphics_key_clr=
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1019 ((mach64_grkey.ckey.blue &0xF8)>>3)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1020 | ((mach64_grkey.ckey.green&0xFC)<<3)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1021 | ((mach64_grkey.ckey.red &0xF8)<<8);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1022 //besr.graphics_key_clr=le2me_32(besr.graphics_key_clr);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1023 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1024 case 24:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1025 besr.graphics_key_msk=0xFFFFFF;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1026 besr.graphics_key_clr=
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1027 ((mach64_grkey.ckey.blue &0xFF))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1028 | ((mach64_grkey.ckey.green&0xFF)<<8)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1029 | ((mach64_grkey.ckey.red &0xFF)<<16);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1030 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1031 case 32:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1032 besr.graphics_key_msk=0xFFFFFF;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1033 besr.graphics_key_clr=
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1034 ((mach64_grkey.ckey.blue &0xFF))
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1035 | ((mach64_grkey.ckey.green&0xFF)<<8)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1036 | ((mach64_grkey.ckey.red &0xFF)<<16);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1037 break;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1038 default:
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1039 besr.ckey_on=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1040 besr.graphics_key_msk=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1041 besr.graphics_key_clr=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1042 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1043 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1044 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1045 {
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1046 besr.ckey_on=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1047 besr.graphics_key_msk=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1048 besr.graphics_key_clr=0;
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1049 }
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1050
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1051 mach64_fifo_wait(4);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1052 OUTREG(OVERLAY_GRAPHICS_KEY_MSK, besr.graphics_key_msk);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1053 OUTREG(OVERLAY_GRAPHICS_KEY_CLR, besr.graphics_key_clr);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1054 // OUTREG(OVERLAY_VIDEO_KEY_MSK, 0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1055 // OUTREG(OVERLAY_VIDEO_KEY_CLR, 0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1056 if(besr.ckey_on)
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1057 OUTREG(OVERLAY_KEY_CNTL,VIDEO_KEY_FN_TRUE|GRAPHIC_KEY_FN_EQ|CMP_MIX_AND);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1058 else
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1059 OUTREG(OVERLAY_KEY_CNTL,VIDEO_KEY_FN_TRUE|GRAPHIC_KEY_FN_TRUE|CMP_MIX_AND);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1060
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1061 return(0);
9a1e26fef45b Move driver files directly into the vidix directory.
diego
parents:
diff changeset
1062 }
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
1063
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
1064 VDXDriver mach64_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
1065 "mach64",
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
1066 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
1067 .probe = mach64_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
1068 .get_caps = mach64_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
1069 .query_fourcc = mach64_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
1070 .init = mach64_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
1071 .destroy = mach64_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
1072 .config_playback = mach64_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
1073 .playback_on = mach64_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
1074 .playback_off = mach64_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
1075 .frame_sel = mach64_frame_sel,
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
1076 .get_eq = mach64_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
1077 .set_eq = mach64_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
1078 .get_gkey = mach64_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
1079 .set_gkey = mach64_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
1080 };