~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.c,v 1.18 2002/12/11 17:23:33 dawes Exp $ */
 
2
/*
 
3
 * includes
 
4
 */
 
5
 
 
6
#include "rendition.h"
 
7
#include "vramdac.h"
 
8
#include "vos.h"
 
9
#include "v1kregs.h"
 
10
#include "v2kregs.h"
 
11
 
 
12
/*
 
13
 * defines
 
14
 */
 
15
 
 
16
#undef DEBUG
 
17
 
 
18
/* directly accessable RAMDAC registers */
 
19
#define BT485_WRITE_ADDR        0x00
 
20
#define BT485_RAMDAC_DATA       0x01    
 
21
#define BT485_PIXEL_MASK        0x02
 
22
#define BT485_READ_ADDR         0x03
 
23
#define BT485_CURS_WR_ADDR      0x04
 
24
#define BT485_CURS_DATA         0x05
 
25
#define BT485_COMMAND_REG_0     0x06
 
26
#define BT485_CURS_RD_ADDR      0x07
 
27
#define BT485_COMMAND_REG_1     0x08
 
28
#define BT485_COMMAND_REG_2     0x09
 
29
#define BT485_STATUS_REG        0x0a
 
30
#define BT485_CURS_RAM_DATA     0x0b
 
31
#define BT485_CURS_X_LOW        0x0c
 
32
#define BT485_CURS_X_HIGH       0x0d
 
33
#define BT485_CURS_Y_LOW        0x0e
 
34
#define BT485_CURS_Y_HIGH       0x0f
 
35
 
 
36
/* indirectly accessable ramdac registers */
 
37
#define BT485_COMMAND_REG_3     0x01
 
38
 
 
39
/* bits in command register 0 */
 
40
#define BT485_CR0_EXTENDED_REG_ACCESS   0x80
 
41
#define BT485_CR0_SCLK_SLEEP_DISABLE    0x40
 
42
#define BT485_CR0_BLANK_PEDESTAL        0x20
 
43
#define BT485_CR0_SYNC_ON_BLUE          0x10
 
44
#define BT485_CR0_SYNC_ON_GREEN         0x08
 
45
#define BT485_CR0_SYNC_ON_RED           0x04
 
46
#define BT485_CR0_8_BIT_DAC             0x02
 
47
#define BT485_CR0_SLEEP_ENABLE          0x01
 
48
 
 
49
/* bits in command register 1 */
 
50
#define BT485_CR1_24BPP             0x00
 
51
#define BT485_CR1_16BPP             0x20
 
52
#define BT485_CR1_8BPP              0x40
 
53
#define BT485_CR1_4BPP              0x60
 
54
#define BT485_CR1_1BPP              0x80
 
55
#define BT485_CR1_BYPASS_CLUT       0x10
 
56
#define BT485_CR1_565_16BPP         0x08
 
57
#define BT485_CR1_555_16BPP         0x00
 
58
#define BT485_CR1_1_TO_1_16BPP      0x04
 
59
#define BT485_CR1_2_TO_1_16BPP      0x00
 
60
#define BT485_CR1_PD7_PIXEL_SWITCH  0x02
 
61
#define BT485_CR1_PIXEL_PORT_CD     0x01
 
62
#define BT485_CR1_PIXEL_PORT_AB     0x00
 
63
 
 
64
/* bits in command register 2 */
 
65
#define BT485_CR2_SCLK_DISABLE      0x80
 
66
#define BT485_TEST_PATH_SELECT      0x40
 
67
#define BT485_PIXEL_INPUT_GATE      0x20
 
68
#define BT485_PIXEL_CLK_SELECT      0x10
 
69
#define BT485_INTERLACE_SELECT      0x08
 
70
#define BT485_16BPP_CLUT_PACKED     0x04
 
71
#define BT485_X_WINDOW_CURSOR       0x03
 
72
#define BT485_2_COLOR_CURSOR        0x02
 
73
#define BT485_3_COLOR_CURSOR        0x01
 
74
#define BT485_DISABLE_CURSOR        0x00
 
75
#define BT485_CURSOR_MASK           0x03
 
76
 
 
77
/* bits in command register 3 */
 
78
#define BT485_4BPP_NIBBLE_SWAP      0x10
 
79
#define BT485_CLOCK_DOUBLER         0x08
 
80
#define BT485_64_BY_64_CURSOR       0x04
 
81
#define BT485_32_BY_32_CURSOR       0x00
 
82
#define BT485_SIZE_MASK             0x04
 
83
 
 
84
/* special constants for the Brooktree BT485 RAMDAC */
 
85
#define BT485_INPUT_LIMIT           110000000 
 
86
 
 
87
 
 
88
 
 
89
/*
 
90
 * local function prototypes
 
91
 */
 
92
 
 
93
static void Bt485_write_masked(IOADDRESS port, vu8 reg, vu8 mask, vu8 data);
 
94
static void Bt485_write_cmd3_masked(IOADDRESS port, vu8 mask, vu8 data);
 
95
#if 0
 
96
static vu8 Bt485_read_masked(IOADDRESS port, vu8 reg, vu8 mask);
 
97
static vu8 Bt485_read_cmd3_masked(IOADDRESS port, vu8 mask);
 
98
#endif
 
99
 
 
100
/*
 
101
 * local data
 
102
 */
 
103
 
 
104
static int Cursor_size=0;
 
105
 
 
106
 
 
107
 
 
108
/*
 
109
 * functions
 
110
 */
 
111
 
 
112
/*
 
113
 * int verite_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
 
114
 *
 
115
 * Used to initialize the ramdac. Palette-bypass is dis-/enabled with respect
 
116
 * to the color depth, the cursor is disabled by default. If needed (i.e. if
 
117
 * the corresponding field in the verite_board_t struct is set), the clock doubling
 
118
 * is turned on.
 
119
 */
 
120
 
 
121
void 
 
122
verite_savedac (ScrnInfoPtr pScreenInfo)
 
123
{
 
124
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
125
    int iob=pRendition->board.io_base + RAMDACBASEADDR;
 
126
    RenditionRegPtr reg = &pRendition->saveRegs;
 
127
 
 
128
    reg->daccmd0 = verite_in8(iob+BT485_COMMAND_REG_0);
 
129
    reg->daccmd1 = verite_in8(iob+BT485_COMMAND_REG_1);
 
130
    reg->daccmd2 = verite_in8(iob+BT485_COMMAND_REG_2);
 
131
    verite_out8(iob+BT485_COMMAND_REG_0,reg->daccmd0 
 
132
                | BT485_CR0_EXTENDED_REG_ACCESS);    
 
133
    verite_out8(iob+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
 
134
    reg->daccmd3 = verite_in8(iob+BT485_STATUS_REG);
 
135
    verite_out8(iob+BT485_COMMAND_REG_0,reg->daccmd0);    
 
136
}
 
137
 
 
138
 
 
139
void
 
140
verite_restoredac (ScrnInfoPtr pScreenInfo, RenditionRegPtr reg)
 
141
{
 
142
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
143
    int iob=pRendition->board.io_base + RAMDACBASEADDR;
 
144
 
 
145
    verite_out8(iob+BT485_COMMAND_REG_0, reg->daccmd0
 
146
                | BT485_CR0_EXTENDED_REG_ACCESS);
 
147
    verite_out8(iob+BT485_COMMAND_REG_1, reg->daccmd1);
 
148
    verite_out8(iob+BT485_COMMAND_REG_2, reg->daccmd2);
 
149
    verite_out8(iob+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
 
150
    verite_out8(iob+BT485_STATUS_REG, reg->daccmd3);
 
151
    verite_out8(iob+BT485_COMMAND_REG_0, reg->daccmd0);
 
152
    
 
153
}
 
154
 
 
155
int
 
156
verite_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
 
157
{
 
158
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
159
    IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
 
160
    vu8 cmd0,cmd1,cmd2;
 
161
    vu8 cmd3_data=0;
 
162
 
 
163
#ifdef DEBUG
 
164
    ErrorF ("Rendition: Debug verite_initdac called\n");
 
165
#endif
 
166
 
 
167
    if (doubleclock)
 
168
        cmd3_data|=BT485_CLOCK_DOUBLER;
 
169
 
 
170
    switch (bpp) {
 
171
        case 1:
 
172
        case 4:
 
173
                        ErrorF("%s %s: color depth %d not (yet ?) supported\n",
 
174
                                X_CONFIG, /*vga256InfoRec.name*/"Rendition", bpp);
 
175
                        return -1;
 
176
 
 
177
        case 8:
 
178
            cmd0 = BT485_CR0_EXTENDED_REG_ACCESS |
 
179
                   BT485_CR0_8_BIT_DAC;
 
180
 
 
181
            cmd1 = BT485_CR1_8BPP |
 
182
                   BT485_CR1_PIXEL_PORT_AB;
 
183
 
 
184
            cmd2 = BT485_PIXEL_INPUT_GATE |
 
185
                   BT485_DISABLE_CURSOR;
 
186
 
 
187
            verite_out8(iob+BT485_COMMAND_REG_0, cmd0);
 
188
            verite_out8(iob+BT485_COMMAND_REG_1, cmd1);
 
189
            verite_out8(iob+BT485_COMMAND_REG_2, cmd2);
 
190
            break;
 
191
 
 
192
        case 16:
 
193
            cmd0 = BT485_CR0_EXTENDED_REG_ACCESS |
 
194
                   BT485_CR0_8_BIT_DAC;
 
195
 
 
196
            cmd1 = BT485_CR1_16BPP |
 
197
                   BT485_CR1_2_TO_1_16BPP |
 
198
                   BT485_CR1_PIXEL_PORT_AB;
 
199
 
 
200
            cmd2 = BT485_PIXEL_INPUT_GATE |
 
201
                   BT485_DISABLE_CURSOR;
 
202
 
 
203
            if (pScreenInfo->defaultVisual == TrueColor)
 
204
              cmd1 |= BT485_CR1_BYPASS_CLUT;
 
205
 
 
206
            if (pScreenInfo->weight.green == 5)
 
207
              cmd1 |= BT485_CR1_555_16BPP;
 
208
            else
 
209
              cmd1 |= BT485_CR1_565_16BPP;
 
210
 
 
211
            verite_out8(iob+BT485_COMMAND_REG_0,cmd0);
 
212
            verite_out8(iob+BT485_COMMAND_REG_1,cmd1);
 
213
            verite_out8(iob+BT485_COMMAND_REG_2,cmd2);
 
214
            break;
 
215
 
 
216
        case 32:
 
217
            cmd0 = BT485_CR0_EXTENDED_REG_ACCESS |
 
218
                   BT485_CR0_8_BIT_DAC;
 
219
 
 
220
            cmd1 = BT485_CR1_24BPP |
 
221
                   BT485_CR1_PIXEL_PORT_AB;
 
222
 
 
223
            cmd2 = BT485_PIXEL_INPUT_GATE |
 
224
                   BT485_DISABLE_CURSOR;
 
225
 
 
226
            if (pScreenInfo->defaultVisual == TrueColor)
 
227
              cmd1 |= BT485_CR1_BYPASS_CLUT;
 
228
 
 
229
            verite_out8(iob+BT485_COMMAND_REG_0,cmd0);
 
230
            verite_out8(iob+BT485_COMMAND_REG_1,cmd1);
 
231
            verite_out8(iob+BT485_COMMAND_REG_2,cmd2);
 
232
            break;
 
233
 
 
234
        default:
 
235
            ErrorF( "%s %s: Color depth not supported (%d bpp)\n",
 
236
                    X_CONFIG, /*vga256InfoRec.name*/"Rendition", bpp);
 
237
            return -1;
 
238
            break;
 
239
    }
 
240
 
 
241
    verite_out8(iob+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
 
242
    verite_out8(iob+BT485_STATUS_REG, cmd3_data);
 
243
/*
 
244
    Bt485_write_masked(iob, BT485_COMMAND_REG_0, 0x7f, 0x00);
 
245
*/
 
246
    verite_out8(iob+BT485_PIXEL_MASK, 0xff);
 
247
 
 
248
    return 0;
 
249
}
 
250
 
 
251
 
 
252
 
 
253
/*
 
254
 * void verite_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
 
255
 *
 
256
 * Used to enable the hardware cursor. Size indicates, whether to use no cursor
 
257
 * at all, a 32x32 or a 64x64 cursor. The type selects a two-color, three-color
 
258
 * or X-window-like cursor. Valid values are defined in vramdac.h. 
 
259
 *
 
260
 */
 
261
void
 
262
verite_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
 
263
{
 
264
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
265
 
 
266
    static vu8 ctypes[]={ BT485_DISABLE_CURSOR, BT485_2_COLOR_CURSOR,
 
267
                      BT485_3_COLOR_CURSOR, BT485_X_WINDOW_CURSOR };
 
268
    static vu8 csizes[]={ BT485_32_BY_32_CURSOR, BT485_64_BY_64_CURSOR };
 
269
  
 
270
    IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
 
271
 
 
272
#ifdef DEBUG
 
273
    ErrorF ("Rendition: Debug verite_enablecursor called type=0x%x\n",type);
 
274
#endif
 
275
    
 
276
    /* type goes to command register 2 */
 
277
    Bt485_write_masked(iob, BT485_COMMAND_REG_2, ~BT485_CURSOR_MASK, 
 
278
                      ctypes[type]);
 
279
  
 
280
    /* size is in command register 3 */
 
281
    Bt485_write_cmd3_masked(iob, ~BT485_SIZE_MASK, csizes[size]);
 
282
 
 
283
    if (type)
 
284
      Cursor_size=(size ? 64 : 32);
 
285
 
 
286
#ifdef DEBUG
 
287
    ErrorF ("Rendition: Debug verite_enablecursor Exit\n");
 
288
#endif
 
289
 
 
290
}
 
291
 
 
292
/*
 
293
 * void verite_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo)
 
294
 *
 
295
 * Moves the cursor to the specified location. To hide the cursor, call
 
296
 * this routine with x=0x0 and y=0x0.
 
297
 *
 
298
 */
 
299
void
 
300
verite_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo)
 
301
{
 
302
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
303
    IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
 
304
 
 
305
    x+=Cursor_size-xo;
 
306
    y+=Cursor_size-yo;
 
307
 
 
308
    verite_out8(iob+BT485_CURS_X_LOW, x&0xff);
 
309
    verite_out8(iob+BT485_CURS_X_HIGH, (x>>8)&0x0f);
 
310
    verite_out8(iob+BT485_CURS_Y_LOW, y&0xff);
 
311
    verite_out8(iob+BT485_CURS_Y_HIGH, (y>>8)&0x0f);
 
312
}
 
313
 
 
314
 
 
315
 
 
316
/*
 
317
 * void verite_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 bg, vu32 fg)
 
318
 *
 
319
 * Sets the color of the cursor -- should be revised for use with 3 colors!
 
320
 *
 
321
 */
 
322
void
 
323
verite_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 fg, vu32 bg)
 
324
{
 
325
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
326
    IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
 
327
 
 
328
#ifdef DEBUG
 
329
    ErrorF ("Rendition: Debug verite_setcursorcolor called FG=0x%x BG=0x%x\n",
 
330
            fg,bg);
 
331
#endif
 
332
 
 
333
    verite_out8(iob+BT485_CURS_WR_ADDR, 0x00);
 
334
 
 
335
    /* load the cursor color 0 */
 
336
    verite_out8(iob+BT485_CURS_DATA, 0x00);
 
337
    verite_out8(iob+BT485_CURS_DATA, 0x00);
 
338
    verite_out8(iob+BT485_CURS_DATA, 0x00);
 
339
 
 
340
    /* load the cursor color 1 */
 
341
    verite_out8(iob+BT485_CURS_DATA, (fg>>16) & 0xff);
 
342
    verite_out8(iob+BT485_CURS_DATA, (fg>>8) & 0xff);
 
343
    verite_out8(iob+BT485_CURS_DATA,  fg&0xff );
 
344
 
 
345
    /* 
 
346
     *  The V2xxx and the V1xxx with external BT485 behave differently.
 
347
     *  If we set color 2 to fg both work correctly.
 
348
     */
 
349
    /* load the cursor color 2 */
 
350
    verite_out8(iob+BT485_CURS_DATA, (fg>>16) & 0xff);
 
351
    verite_out8(iob+BT485_CURS_DATA, (fg>>8) & 0xff);
 
352
    verite_out8(iob+BT485_CURS_DATA,  fg & 0xff);
 
353
 
 
354
    /* load the cursor color 3 */
 
355
    verite_out8(iob+BT485_CURS_DATA, (bg>>16)&0xff );
 
356
    verite_out8(iob+BT485_CURS_DATA, (bg>>8)&0xff );
 
357
    verite_out8(iob+BT485_CURS_DATA, bg&0xff );
 
358
}
 
359
 
 
360
 
 
361
 
 
362
/*
 
363
 * Oh god, this code is quite a mess ... should be re-written soon.
 
364
 * But for now I'm happy it works ;) <ml> 
 
365
 *
 
366
 */
 
367
void
 
368
verite_loadcursor(ScrnInfoPtr pScreenInfo, vu8 size, vu8 *cursorimage)
 
369
{
 
370
    int c, bytes, row;
 
371
    vu8 *src = cursorimage;
 
372
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
373
    IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
 
374
    vu8 tmp;
 
375
    vu8 memend; /* Added for byte-swap fix */
 
376
 
 
377
#ifdef DEBUG
 
378
    ErrorF ("Rendition: Debug verite_loadcursor called\n");
 
379
#endif
 
380
 
 
381
    if (NULL == cursorimage) 
 
382
        return;
 
383
 
 
384
    /* Following two lines added for the byte-swap fix */
 
385
    memend = verite_in8(pRendition->board.io_base + MEMENDIAN);
 
386
    verite_out8(pRendition->board.io_base + MEMENDIAN, MEMENDIAN_HW);
 
387
 
 
388
    size&=1;
 
389
    if (size)
 
390
        bytes=64;
 
391
    else
 
392
        bytes=32;
 
393
    bytes=(bytes*bytes)>>3;
 
394
 
 
395
    if (pRendition->board.chip == V1000_DEVICE) {
 
396
      /* now load the cursor data into the cursor ram */
 
397
 
 
398
      tmp=verite_in8(iob+BT485_COMMAND_REG_0)&0x7f;
 
399
      verite_out8(iob+BT485_COMMAND_REG_0, tmp|0x80);
 
400
 
 
401
      verite_out8(iob+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
 
402
 
 
403
      tmp=verite_in8(iob+BT485_STATUS_REG)&0xf8;
 
404
      verite_out8(iob+BT485_STATUS_REG, tmp|(size<<2));
 
405
      verite_out8(iob+BT485_WRITE_ADDR, 0x00);
 
406
 
 
407
      /* output cursor image */
 
408
      src=cursorimage;
 
409
      
 
410
      /* First plane data */
 
411
      for (c=0; c<bytes; c++)  {
 
412
        verite_out8(iob+BT485_CURS_RAM_DATA, *src);
 
413
        src+=2;
 
414
      }
 
415
 
 
416
      /* Second plane data */
 
417
      src=cursorimage+1;
 
418
      for (c=0; c<bytes; c++)  {
 
419
        verite_out8(iob+BT485_CURS_RAM_DATA, *src);
 
420
        src+=2;
 
421
      }
 
422
    }
 
423
    else {
 
424
      /* V2x00 HW-Cursor, supports only 64x64x2 size */
 
425
 
 
426
      verite_out32(iob+CURSORBASE, pRendition->board.hwcursor_membase);
 
427
 
 
428
      /* First plane data */
 
429
      for (row=0; row<64; row++)
 
430
        for (c=0, src=cursorimage+1+16*row; c<8; c++, src+=2)
 
431
          verite_write_memory8(pRendition->board.vmem_base, 16*(63-row)+c,
 
432
                          (c&1)?(*(src-2)):(*(src+2)));
 
433
      /* Second plane data */
 
434
      for (row=0; row<64; row++)
 
435
        for (c=0, src=cursorimage+16*row; c<8; c++, src+=2)
 
436
          verite_write_memory8(pRendition->board.vmem_base, 8+16*(63-row)+c,
 
437
                          (c&1)?(*(src-2)):(*(src+2)));
 
438
 
 
439
    }
 
440
    /* Following line added for the byte-swap fix */
 
441
    verite_out8(pRendition->board.io_base + MEMENDIAN, memend);
 
442
}
 
443
 
 
444
 
 
445
 
 
446
/* NOTE: count is the actual number of colors decremented by 1 */
 
447
 
 
448
void
 
449
verite_setpalette(ScrnInfoPtr pScreenInfo, int numColors, int *indices,
 
450
                LOCO *colors, VisualPtr pVisual)
 
451
{
 
452
    renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
 
453
    IOADDRESS iob=pRendition->board.io_base;
 
454
    vu32 crtc_status;
 
455
    int i, index;
 
456
 
 
457
#ifdef DEBUG
 
458
    ErrorF ("Rendition: Debug verite_setpalette called\n");
 
459
#endif
 
460
 
 
461
    while (1) {
 
462
        crtc_status=verite_in32(iob+CRTCSTATUS);
 
463
        if (crtc_status & CRTCSTATUS_VERT_SYNC) 
 
464
            break;
 
465
    };
 
466
 
 
467
    iob+=RAMDACBASEADDR;
 
468
 
 
469
    for (i = 0; i < numColors; i++) {
 
470
        index = indices[i];
 
471
        verite_out8(iob+BT485_WRITE_ADDR, index);
 
472
 
 
473
        verite_out8(iob+BT485_RAMDAC_DATA, colors[index].red);
 
474
        verite_out8(iob+BT485_RAMDAC_DATA, colors[index].green);
 
475
        verite_out8(iob+BT485_RAMDAC_DATA, colors[index].blue);
 
476
    }
 
477
}
 
478
 
 
479
/*
 
480
 * local functions
 
481
 */
 
482
 
 
483
/*
 
484
 * static void Bt485_write_masked(IOADDRESS port, vu8 reg, vu8 mask, vu8 data)
 
485
 *
 
486
 *
 
487
 */
 
488
static void
 
489
Bt485_write_masked(IOADDRESS port, vu8 reg, vu8 mask, vu8 data)
 
490
{
 
491
    vu8 tmp;
 
492
 
 
493
    tmp=verite_in8(port+reg)&mask;
 
494
    verite_out8(port+reg, tmp|data);
 
495
}
 
496
 
 
497
 
 
498
 
 
499
/*
 
500
 * static void Bt485_write_cmd3_masked(IOADDRESS port, vu8 mask, vu8 data)
 
501
 *
 
502
 *
 
503
 */
 
504
static void
 
505
Bt485_write_cmd3_masked(IOADDRESS port, vu8 mask, vu8 data)
 
506
{
 
507
/*
 
508
 *   Bt485_write_masked(port, BT485_COMMAND_REG_0, 0x7f, 0x80);
 
509
 */
 
510
    verite_out8(port+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
 
511
    Bt485_write_masked(port, BT485_STATUS_REG, mask, data);
 
512
/*
 
513
 *    Bt485_write_masked(port, BT485_COMMAND_REG_0, 0x7f, 0x00);
 
514
 */
 
515
}
 
516
 
 
517
 
 
518
 
 
519
#if 0
 
520
/*
 
521
 * static vu8 Bt485_read_masked(IOADDRESS port, vu8 reg, vu8 mask)
 
522
 *
 
523
 *
 
524
 */
 
525
static vu8
 
526
Bt485_read_masked(IOADDRESS port, vu8 reg, vu8 mask)
 
527
{
 
528
    return verite_in8(port+reg)&mask;
 
529
}
 
530
 
 
531
 
 
532
/*
 
533
 * static vu8 Bt485_read_cmd3_masked(IOADDRESS port, vu8 mask)
 
534
 *
 
535
 *
 
536
 */
 
537
static vu8
 
538
Bt485_read_cmd3_masked(IOADDRESS port, vu8 mask)
 
539
{
 
540
    vu8 value;
 
541
 
 
542
    Bt485_write_masked(port, BT485_COMMAND_REG_0, 0x7f, 0x80);
 
543
    verite_out8(port+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
 
544
    value=Bt485_read_masked(port, BT485_STATUS_REG, mask);
 
545
    Bt485_write_masked(port, BT485_COMMAND_REG_0, 0x7f, 0x00);
 
546
 
 
547
    return value;
 
548
}
 
549
#endif
 
550
 
 
551
 
 
552
/*
 
553
 * end of file vramdac.c
 
554
 */