Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1029 serge 1
 
2
3
 
4
5
 
6
7
 
8
 
9
{
10
    CHIP_FAMILY_UNKNOW,
11
    CHIP_FAMILY_LEGACY,
12
    CHIP_FAMILY_RADEON,
13
    CHIP_FAMILY_RV100,
14
    CHIP_FAMILY_RS100,    /* U1 (IGP320M) or A3 (IGP320)*/
15
    CHIP_FAMILY_RV200,
16
    CHIP_FAMILY_RS200,    /* U2 (IGP330M/340M/350M) or A4 (IGP330/340/345/350), RS250 (IGP 7000) */
17
    CHIP_FAMILY_R200,
18
    CHIP_FAMILY_RV250,
19
    CHIP_FAMILY_RS300,    /* RS300/RS350 */
20
    CHIP_FAMILY_RV280,
21
    CHIP_FAMILY_R300,
22
    CHIP_FAMILY_R350,
23
    CHIP_FAMILY_RV350,
24
    CHIP_FAMILY_RV380,    /* RV370/RV380/M22/M24 */
25
    CHIP_FAMILY_R420,     /* R420/R423/M18 */
26
    CHIP_FAMILY_RV410,    /* RV410, M26 */
27
    CHIP_FAMILY_RS400,    /* xpress 200, 200m (RS400) Intel */
28
    CHIP_FAMILY_RS480,    /* xpress 200, 200m (RS410/480/482/485) AMD */
29
    CHIP_FAMILY_RV515,    /* rv515 */
30
    CHIP_FAMILY_R520,     /* r520 */
31
    CHIP_FAMILY_RV530,    /* rv530 */
32
    CHIP_FAMILY_R580,     /* r580 */
33
    CHIP_FAMILY_RV560,    /* rv560 */
34
    CHIP_FAMILY_RV570,    /* rv570 */
35
    CHIP_FAMILY_RS600,
36
    CHIP_FAMILY_RS690,
37
    CHIP_FAMILY_RS740,
38
    CHIP_FAMILY_R600,     /* r600 */
39
    CHIP_FAMILY_R630,
40
    CHIP_FAMILY_RV610,
41
    CHIP_FAMILY_RV630,
42
    CHIP_FAMILY_RV670,
43
    CHIP_FAMILY_RV620,
44
    CHIP_FAMILY_RV635,
45
    CHIP_FAMILY_RS780,
46
    CHIP_FAMILY_RV770,
47
    CHIP_FAMILY_LAST
48
} RADEONChipFamily;
49
50
 
51
        (rhdPtr->ChipFamily == CHIP_FAMILY_RV200)  ||  \
52
        (rhdPtr->ChipFamily == CHIP_FAMILY_RS100)  ||  \
53
        (rhdPtr->ChipFamily == CHIP_FAMILY_RS200)  ||  \
54
        (rhdPtr->ChipFamily == CHIP_FAMILY_RV250)  ||  \
55
        (rhdPtr->ChipFamily == CHIP_FAMILY_RV280)  ||  \
56
        (rhdPtr->ChipFamily == CHIP_FAMILY_RS300))
57
58
 
59
 
60
        (info->ChipFamily == CHIP_FAMILY_RV350) ||  \
61
        (info->ChipFamily == CHIP_FAMILY_R350)  ||  \
62
        (info->ChipFamily == CHIP_FAMILY_RV380) ||  \
63
        (info->ChipFamily == CHIP_FAMILY_R420)  ||  \
64
        (info->ChipFamily == CHIP_FAMILY_RV410) ||  \
65
        (info->ChipFamily == CHIP_FAMILY_RS400) ||  \
66
        (info->ChipFamily == CHIP_FAMILY_RS480))
67
68
 
69
70
 
71
72
 
73
	(info->ChipFamily == CHIP_FAMILY_R520)   ||  \
74
	(info->ChipFamily == CHIP_FAMILY_RV530)  ||  \
75
	(info->ChipFamily == CHIP_FAMILY_R580)   ||  \
76
	(info->ChipFamily == CHIP_FAMILY_RV560)  ||  \
77
	(info->ChipFamily == CHIP_FAMILY_RV570))
78
79
 
80
	(info->ChipFamily == CHIP_FAMILY_RV350) ||  \
81
	(info->ChipFamily == CHIP_FAMILY_R350)  ||  \
82
	(info->ChipFamily == CHIP_FAMILY_RV380) ||  \
83
	(info->ChipFamily == CHIP_FAMILY_R420)  ||  \
84
	(info->ChipFamily == CHIP_FAMILY_RV410) ||  \
85
	(info->ChipFamily == CHIP_FAMILY_RS690) ||  \
86
	(info->ChipFamily == CHIP_FAMILY_RS600) ||  \
87
	(info->ChipFamily == CHIP_FAMILY_RS740) ||  \
88
	(info->ChipFamily == CHIP_FAMILY_RS400) ||  \
89
    (info->ChipFamily == CHIP_FAMILY_RS480))
90
91
 
92
 
93
	CARD_PCI,
94
	CARD_AGP,
95
	CARD_PCIE
96
} RADEONCardType;
97
98
 
99
    RADEON_FAMILY_MASK  =  0x0000ffffUL,
100
    RADEON_FLAGS_MASK   =  0xffff0000UL,
101
    RADEON_IS_MOBILITY  =  0x00010000UL,
102
    RADEON_IS_IGP       =  0x00020000UL,
103
    RADEON_SINGLE_CRTC  =  0x00040000UL,
104
    RADEON_IS_AGP       =  0x00080000UL,
105
    RADEON_HAS_HIERZ    =  0x00100000UL,
106
    RADEON_IS_PCIE      =  0x00200000UL,
107
    RADEON_NEW_MEMMAP   =  0x00400000UL,
108
    RADEON_IS_PCI       =  0x00800000UL,
109
    RADEON_IS_IGPGART   =  0x01000000UL,
110
};
111
112
 
113
 
114
 * Errata workarounds
115
 */
116
typedef enum {
117
       CHIP_ERRATA_R300_CG             = 0x00000001,
118
       CHIP_ERRATA_PLL_DUMMYREADS      = 0x00000002,
119
       CHIP_ERRATA_PLL_DELAY           = 0x00000004
120
} RADEONErrata;
121
122
 
123
{
124
    u32_t pci_device_id;
125
    RADEONChipFamily chip_family;
126
    int mobility;
127
    int igp;
128
    int nocrtc2;
129
    int nointtvout;
130
    int singledac;
131
} RADEONCardInfo;
132
133
 
134
 
135
#define RHD_MMIO_BAR       2
136
137
 
138
#define RHD_MEM_FB         2
139
140
 
141
#define R300_DEFAULT_GART_SIZE           32      /* MB (for R300 and above) */
142
#define RADEON_DEFAULT_RING_SIZE         1       /* MB (must be page aligned) */
143
#define RADEON_DEFAULT_BUFFER_SIZE       2       /* MB (must be page aligned) */
144
#define RADEON_DEFAULT_GART_TEX_SIZE     1       /* MB (must be page aligned) */
145
146
 
147
148
 
149
150
 
151
152
 
153
#define RADEON_TIMEOUT    4000000 /* Fall out of wait loops after this count */
154
155
 
156
 
157
{
158
  addr_t            MMIOBase;
159
  size_t            MMIOMapSize;
160
161
 
162
163
 
164
  addr_t            FbFreeSize;
165
166
 
167
//  unsigned int      FbScanoutStart;
168
//  unsigned int      FbScanoutSize;
169
170
 
171
172
 
173
  u32_t             mc_fb_location;
174
  u32_t             mc_agp_location;
175
  u32_t             mc_agp_location_hi;
176
177
 
178
179
 
180
  u32_t             BusCntl;
181
  unsigned long     FbMapSize;            /* Size of frame buffer, in bytes    */
182
  unsigned long     FbSecureSize;         /* Size of secured fb area at end of
183
                                            framebuffer */
184
185
 
186
  RADEONErrata      ChipErrata;
187
188
 
189
190
 
191
  Bool              IsMobility;
192
  Bool              HasCRTC2;
193
194
 
195
  u32_t             devfn;
196
197
 
198
  u16_t             PciDeviceID;
199
200
 
201
  u16_t             subdevice_id;
202
203
 
204
205
 
206
  u32_t             ioBase[6];
207
  u32_t             memtype[6];
208
  u32_t             memsize[6];
209
210
 
211
  struct mem_block  *gart_heap;
212
213
 
214
  u32_t             displayHeight;
215
216
 
217
  u32_t            *gart_table;
218
  addr_t            gart_table_dma;
219
  addr_t            gart_vm_start;
220
  size_t            gart_size;
221
222
 
223
  u32_t             ring_rp;
224
  u32_t             ring_wp;
225
  u32_t             ringSize;
226
  u32_t             ring_avail;
227
228
 
229
  u32_t             pciAperSize;
230
  u32_t             CPusecTimeout;
231
232
 
233
  int               __ymin;
234
  int               __xmax;
235
  int               __ymax;
236
237
 
238
  u32_t             dst_pitch_offset;
239
  u32_t             surface_cntl;
240
241
 
242
 
243
244
 
245
  volatile u32_t    scratch1;
246
  volatile u32_t    scratch2;
247
  volatile u32_t    scratch3;
248
  volatile u32_t    scratch4;
249
  volatile u32_t    scratch5;
250
  volatile u32_t    scratch6;
251
  volatile u32_t    scratch7;
252
253
 
254
  Bool              IsDDR;
255
256
 
257
  int               has_tcl;
258
259
 
260
261
 
262
263
 
264
#define RADEON_CP_PACKET1              0x40000000
265
#define RADEON_CP_PACKET2              0x80000000
266
#define RADEON_CP_PACKET3              0xC0000000
267
268
 
269
# define RADEON_CNTL_BITBLT            0x00009200
270
# define RADEON_CNTL_TRANBLT           0x00009C00
271
272
 
273
# define RADEON_CNTL_PAINT_MULTI       0x00009A00
274
275
 
276
277
 
278
#define FINISH_ACCEL()
279
#define COMMIT_RING()
280
#define OUT_ACCEL_REG(reg, val) OUTREG(reg, val)
281
282
 
283
284
 
285
    (RADEON_CP_PACKET0 | ((n - 1 ) << 16) | ((reg) >> 2))
286
287
 
288
	(RADEON_CP_PACKET1 | (((reg1) >> 2) << 11) | ((reg0) >> 2))
289
290
 
291
  (RADEON_CP_PACKET2)
292
293
 
294
	(RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
295
296
 
297
 
298
     int avail = rhd.ring_rp-rhd.ring_wp;                          \
299
     if (avail <=0 ) avail+= 0x4000;                               \
300
     if( (req)+128 > avail)                                        \
301
     {                                                             \
302
        rhd.ring_rp = INREG(RADEON_CP_RB_RPTR);                    \
303
        avail = rhd.ring_rp-rhd.ring_wp;                           \
304
        if (avail <= 0) avail+= 0x4000;                            \
305
        if( (req)+128 > avail){                                    \
306
           unlock_device();                                        \
307
           return 0;                                               \
308
        };                                                         \
309
     }                                                             \
310
     ring = &rhd.ringBase[rhd.ring_wp];                            \
311
}while(0)
312
313
 
314
315
 
316
317
 
318
do {                                     \
319
    ring[0]  = CP_PACKET0((reg), 1);     \
320
    ring[1]  = (val);                    \
321
    ring+=  2;                           \
322
} while (0)
323
324
 
325
326
 
327
  rhd.ring_wp = (ring - rhd.ringBase) & 0x3FFF;        \
328
  /* Flush writes to ring */                           \
329
    DRM_MEMORYBARRIER();                               \
330
  /*GET_RING_HEAD( dev_priv );          */             \
331
  OUTREG( RADEON_CP_RB_WPTR, rhd.ring_wp);             \
332
    /* read from PCI bus to ensure correct posting */  \
333
/*  INREG( RADEON_CP_RB_RPTR );    */                  \
334
} while (0)
335
336
 
337
#define FINISH_ACCEL()          COMMIT_RING()
338
339
 
340
341
 
342
343
 
344
    int			token;		/* id of the token */
345
    const char *	name;		/* token name */
346
} SymTabRec, *SymTabPtr;
347
348
 
349
 
350
{
351
     __asm__ __volatile__ (
352
     "call *__imp__WaitMutex"
353
     ::"b" (&rhd.lock));
354
};
355
356
 
357
{
358
    rhd.lock = 0;
359
}
360
361
 
362
OUTREG8(u16_t offset, u8_t value)
363
{
364
  *(volatile u8_t *)((u8_t *)(rhd.MMIOBase + offset)) = value;
365
}
366
367
 
368
 
369
{
370
  return *(volatile u32_t *)((u8_t*)(rhd.MMIOBase + offset));
371
}
372
373
 
374
 
375
{
376
  *(volatile u32_t *)((u8_t *)(rhd.MMIOBase + offset)) = value;
377
}
378
379
 
380
//  *(volatile u32_t *)((u8_t *)(rhd.MMIOBase + (u32_t)(offset))) = (u32_t)value
381
382
 
383
 
384
{
385
  return *(volatile u32_t *)((u8_t*)(rhdPtr->MMIOBase + offset));
386
}
387
388
 
389
MASKREG(u16_t offset, u32_t value, u32_t mask)
390
{
391
  u32_t tmp;
392
393
 
394
  tmp &= ~mask;
395
  tmp |= (value & mask);
396
  OUTREG(offset, tmp);
397
};
398
399
 
400
 
401
402
 
403
404
 
405
 
406
_RHDRegWrite(RHDPtr rhdPtr, u16_t offset, u32_t value)
407
{
408
  *(volatile u32_t *)((u8_t *)(rhdPtr->MMIOBase + offset)) = value;
409
}
410
411
 
412
_RHDRegMask(RHDPtr rhdPtr, u16_t offset, u32_t value, u32_t mask)
413
{
414
  u32_t tmp;
415
416
 
417
  tmp &= ~mask;
418
  tmp |= (value & mask);
419
  _RHDRegWrite(rhdPtr, offset, tmp);
420
};
421
422
 
423
#define RHDRegWrite(ptr, offset, value) _RHDRegWrite((ptr)->rhdPtr, (offset), (value))
424
#define RHDRegMask(ptr, offset, value, mask) _RHDRegMask((ptr)->rhdPtr, (offset), (value), (mask))
425
426
 
427
 
428
429
 
430
//  #define DBG(x)
431
432
 
433
typedef struct s_cursor
434
{
435
   u32_t   magic;                           // 'CURS'
436
   void  (*destroy)(struct s_cursor*);    // destructor
437
   u32_t   fd;                              // next object in list
438
   u32_t   bk;                              // prev object in list
439
   u32_t   pid;                             // owner id
440
441
 
442
   u32_t   hot_x;                           // hotspot coords
443
   u32_t   hot_y;
444
}cursor_t;
445
#pragma pack (pop)
446
447
 
448
#define LOAD_FROM_MEM    1
449
#define LOAD_INDIRECT    2
450
451
 
452
void __stdcall copy_cursor(void *img, void *src);
453
void destroy_cursor(cursor_t *cursor);
454
void __destroy_cursor(cursor_t *cursor);                // wrap
455
456
 
457
void __stdcall r500_SetCursor(cursor_t *cursor, int x, int y);
458
void __stdcall r500_CursorRestore(int x, int y);
459
460
 
461
 
462
    u32_t x ;
463
    u32_t y ;
464
} xPointFixed;
465
466
 
467
468
 
469
470
 
471
472
 
473
#define IntToxFixed(i)  ((xFixed) (i) << XFIXED_BITS)
474
475
 
476
477
 
478
					 ((type) << 16) | \
479
					 ((a) << 12) | \
480
					 ((r) << 8) | \
481
					 ((g) << 4) | \
482
					 ((b)))
483
484
 
485
#define PICT_FORMAT_RGB(f)  (((f)      ) & 0xfff)
486
487
 
488
#define PICT_TYPE_A     1
489
#define PICT_TYPE_ARGB	2
490
#define PICT_TYPE_ABGR	3
491
#define PICT_TYPE_COLOR	4
492
#define PICT_TYPE_GRAY	5
493
494
 
495
   PICT_a8r8g8b8 =	PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8),
496
   PICT_x8r8g8b8 =	PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8),
497
   PICT_a8b8g8r8 =	PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8),
498
   PICT_x8b8g8r8 =	PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8),
499
500
 
501
   PICT_r8g8b8 =	PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8),
502
   PICT_b8g8r8 =	PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8),
503
504
 
505
   PICT_r5g6b5 =	PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5),
506
   PICT_b5g6r5 =	PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5),
507
508
 
509
   PICT_x1r5g5b5 =	PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5),
510
   PICT_a1b5g5r5 =	PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5),
511
   PICT_x1b5g5r5 =	PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5),
512
   PICT_a4r4g4b4 =	PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4),
513
   PICT_x4r4g4b4 =	PICT_FORMAT(16,PICT_TYPE_ARGB,0,4,4,4),
514
   PICT_a4b4g4r4 =	PICT_FORMAT(16,PICT_TYPE_ABGR,4,4,4,4),
515
   PICT_x4b4g4r4 =	PICT_FORMAT(16,PICT_TYPE_ABGR,0,4,4,4),
516
517
 
518
   PICT_a8 =		PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0),
519
   PICT_r3g3b2 =	PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2),
520
   PICT_b2g3r3 =	PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2),
521
   PICT_a2r2g2b2 =	PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2),
522
   PICT_a2b2g2r2 =	PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2),
523
524
 
525
   PICT_g8 =		PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0),
526
527
 
528
529
 
530
   PICT_x4g4 =		PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0),
531
532
 
533
   PICT_a4 =		PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0),
534
   PICT_r1g2b1 =	PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1),
535
   PICT_b1g2r1 =	PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1),
536
   PICT_a1r1g1b1 =	PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1),
537
   PICT_a1b1g1r1 =	PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1),
538
539
 
540
   PICT_g4 =		PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0),
541
542
 
543
   PICT_a1 =		PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0),
544
545
 
546
} PictFormatShort;
547
548
 
549
550
 
551
 
552
 
553
554
 
555
static void init_pipes(RHDPtr info);
556
Bool   init_cp(RHDPtr info);
557
558
 
559
560
 
561
562
 
563
564
 
565
566
 
567