1
/* Copyright (c) 2005 Advanced Micro Devices, Inc.
3
* Permission is hereby granted, free of charge, to any person obtaining a copy
4
* of this software and associated documentation files (the "Software"), to
5
* deal in the Software without restriction, including without limitation the
6
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
* sell copies of the Software, and to permit persons to whom the Software is
8
* furnished to do so, subject to the following conditions:
10
* The above copyright notice and this permission notice shall be included in
11
* all copies or substantial portions of the Software.
13
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
* Neither the name of the Advanced Micro Devices, Inc. nor the names of its
22
* contributors may be used to endorse or promote products derived from this
23
* software without specific prior written permission.
26
void gu1_enable_compression(void); /* private routine definition */
27
void gu1_disable_compression(void); /* private routine definition */
28
void gfx_reset_video(void); /* private routine definition */
29
int gfx_set_display_control(int sync_polarities); /* private routine
31
int gu1_set_specified_mode(DISPLAYMODE * pMode, int bpp);
33
/* VIDEO BUFFER SIZE */
35
unsigned long vid_buf_size = 0;
38
/*----------------------------------------------------------------------------
39
* GU1_DELAY_APPROXIMATE (PRIVATE ROUTINE - NOT PART OF DURANGO API)
41
* Delay the requested number of milliseconds by reading a register. This
42
* function generally takes longer than the requested time.
43
*----------------------------------------------------------------------------
46
#define READS_PER_MILLISECOND 60000L
49
gu1_delay_approximate(unsigned long milliseconds)
51
/* ASSUME 300 MHz, 5 CLOCKS PER READ */
55
loop = milliseconds * READS_PER_MILLISECOND;
57
READ_REG32(DC_UNLOCK);
61
/*----------------------------------------------------------------------------
62
* GU1_DELAY_PRECISE (PRIVATE ROUTINE - NOT PART OF DURANGO API)
64
* Delay the number of milliseconds on a more precise level, varying only by
65
* 1/10 of a ms. This function should only be called if an SC1200 is present.
66
*----------------------------------------------------------------------------
69
gu1_delay_precise(unsigned long milliseconds)
74
unsigned long i, timer_start, timer_end, total_ticks, previous_ticks,
77
/* Get current time */
78
timer_start = IND(SC1200_CB_BASE_ADDR + SC1200_CB_TMVALUE);
80
/* Calculate expected end time */
81
if (INB(SC1200_CB_BASE_ADDR + SC1200_CB_TMCNFG) & SC1200_TMCLKSEL_27MHZ)
82
total_ticks = 27000 * milliseconds; /* timer resolution is 27 MHz */
84
total_ticks = 1000 * milliseconds; /* timer resolution is 1 MHz */
86
if (total_ticks > ((unsigned long) 0xffffffff - timer_start))
88
timer_end = total_ticks - ((unsigned long) 0xffffffff - timer_start);
90
timer_end = timer_start + total_ticks;
92
/* in case of wrap around */
93
if (timer_end < timer_start) {
94
previous_ticks = timer_start;
96
temp_ticks = IND(SC1200_CB_BASE_ADDR + SC1200_CB_TMVALUE);
97
if (temp_ticks < previous_ticks)
100
previous_ticks = temp_ticks;
101
for (i = 0; i < LOOP; i++)
102
READ_REG32(DC_UNLOCK);
106
/* now the non-wrap around part */
108
for (i = 0; i < LOOP; i++)
109
READ_REG32(DC_UNLOCK);
110
if (IND(SC1200_CB_BASE_ADDR + SC1200_CB_TMVALUE) > timer_end)
113
#endif /* GFX_VIDEO_SC1200 */
116
/*----------------------------------------------------------------------------
117
* WARNING!!!! INACCURATE DELAY MECHANISM
119
* In an effort to keep the code self contained and operating system
120
* independent, the delay loop just performs reads of a display controller
121
* register. This time will vary for faster processors. The delay can always
122
* be longer than intended, only effecting the time of the mode switch
123
* (obviously want it to still be under a second). Problems with the hardware
124
* only arise if the delay is not long enough.
126
* For the SC1200, the high resolution timer can be used as an accurate
127
* mechanism for keeping time. However, in order to avoid a busy loop of IO
128
* reads, the timer is polled in-between busy loops, and therefore the actual
129
* delay might be longer than the requested delay by the time of one busy loop
130
* (which on a 200 MHz system took 95 us)
132
* There are thus two delay functions which are called from the main API
134
* One is meant to be more precise and should only called if an SC1200 is
136
*----------------------------------------------------------------------------
138
#if GFX_DISPLAY_DYNAMIC
140
gu1_delay_milliseconds(unsigned long milliseconds)
143
gfx_delay_milliseconds(unsigned long milliseconds)
147
#if GFX_VIDEO_DYNAMIC
148
if (gfx_video_type == GFX_VIDEO_TYPE_SC1200) {
150
gu1_delay_precise(milliseconds);
152
#if GFX_VIDEO_DYNAMIC
155
#endif /* GFX_VIDEO_SC1200 */
156
gu1_delay_approximate(milliseconds);
159
#if GFX_DISPLAY_DYNAMIC
161
gu1_delay_microseconds(unsigned long microseconds)
164
gfx_delay_microseconds(unsigned long microseconds)
167
/* ASSUME 300 MHz, 2 CLOCKS PER INCREMENT */
168
unsigned long loop_count = microseconds * 150;
170
while (loop_count-- > 0) {
175
/*----------------------------------------------------------------------------
178
* This routine disables the display controller output.
179
*----------------------------------------------------------------------------
182
gu1_video_shutdown(void)
184
unsigned long unlock;
185
unsigned long gcfg, tcfg;
187
/* DISABLE COMPRESSION */
188
gu1_disable_compression();
190
/* ALSO DISABLE VIDEO */
191
/* Use private "reset video" routine to do all that is needed. */
192
/* SC1200, for example, also disables the alpha blending regions. */
195
/* UNLOCK THE DISPLAY CONTROLLER REGISTERS */
196
unlock = READ_REG32(DC_UNLOCK);
197
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
199
/* READ THE CURRENT GX VALUES */
200
gcfg = READ_REG32(DC_GENERAL_CFG);
201
tcfg = READ_REG32(DC_TIMING_CFG);
203
/* BLANK THE GX DISPLAY AND DISABLE THE TIMING GENERATOR */
204
tcfg &= ~((unsigned long) DC_TCFG_BLKE | (unsigned long) DC_TCFG_TGEN);
205
WRITE_REG32(DC_TIMING_CFG, tcfg);
207
/* DELAY: WAIT FOR PENDING MEMORY REQUESTS */
208
/* This delay is used to make sure that all pending requests to the */
209
/* memory controller have completed before disabling the FIFO load. */
210
gfx_delay_milliseconds(1);
212
/* DISABLE DISPLAY FIFO LOAD AND DISABLE COMPRESSION */
213
gcfg &= ~(unsigned long) (DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE);
214
WRITE_REG32(DC_GENERAL_CFG, gcfg);
215
WRITE_REG32(DC_UNLOCK, unlock);
219
/*----------------------------------------------------------------------------
220
* GFX_SET_DISPLAY_BPP
222
* This routine programs the bpp in the display controller.
223
*----------------------------------------------------------------------------
225
#if GFX_DISPLAY_DYNAMIC
227
gu1_set_display_bpp(unsigned short bpp)
230
gfx_set_display_bpp(unsigned short bpp)
233
unsigned long ocfg, lock;
235
lock = READ_REG32(DC_UNLOCK);
236
ocfg = READ_REG32(DC_OUTPUT_CFG) & ~(DC_OCFG_8BPP | DC_OCFG_555);
238
/* SET DC PIXEL FORMAT */
240
ocfg |= DC_OCFG_8BPP;
244
return GFX_STATUS_BAD_PARAMETER;
246
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
247
WRITE_REG32(DC_OUTPUT_CFG, ocfg);
248
WRITE_REG32(DC_UNLOCK, lock);
250
/* SET BPP IN GRAPHICS PIPELINE */
256
/*----------------------------------------------------------------------------
257
* GFX_SET_SPECIFIED_MODE
258
* This routine uses the parameters in the specified display mode structure
259
* to program the display controller hardware.
260
*----------------------------------------------------------------------------
263
gu1_set_specified_mode(DISPLAYMODE * pMode, int bpp)
265
unsigned long unlock, value;
266
unsigned long gcfg, tcfg, ocfg;
267
unsigned long size, pitch;
268
unsigned long hactive, vactive;
272
/* CHECK WHETHER TIMING CHANGE IS ALLOWED */
273
/* Flag used for locking also overrides timing change restriction */
274
if (gfx_timing_lock && !(pMode->flags & GFX_MODE_LOCK_TIMING))
275
return GFX_STATUS_ERROR;
277
/* SET GLOBAL FLAG */
278
if (pMode->flags & GFX_MODE_LOCK_TIMING)
281
/* DISABLE COMPRESSION */
282
gu1_disable_compression();
284
/* ALSO DISABLE VIDEO */
285
/* Use private "reset video" routine to do all that is needed. */
286
/* SC1200, for example, also disables the alpha blending regions. */
289
/* UNLOCK THE DISPLAY CONTROLLER REGISTERS */
290
unlock = READ_REG32(DC_UNLOCK);
291
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
293
/* READ THE CURRENT GX VALUES */
294
gcfg = READ_REG32(DC_GENERAL_CFG);
295
tcfg = READ_REG32(DC_TIMING_CFG);
297
/* BLANK THE GX DISPLAY AND DISABLE THE TIMING GENERATOR */
298
tcfg &= ~((unsigned long) DC_TCFG_BLKE | (unsigned long) DC_TCFG_TGEN);
299
WRITE_REG32(DC_TIMING_CFG, tcfg);
301
/* DELAY: WAIT FOR PENDING MEMORY REQUESTS
302
* This delay is used to make sure that all pending requests to the
303
* memory controller have completed before disabling the FIFO load.
305
gfx_delay_milliseconds(1);
307
/* DISABLE DISPLAY FIFO LOAD AND DISABLE COMPRESSION */
308
gcfg &= ~(unsigned long) (DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE);
309
WRITE_REG32(DC_GENERAL_CFG, gcfg);
311
/* CLEAR THE "DCLK_MUL" FIELD */
312
gcfg &= ~(unsigned long) (DC_GCFG_DDCK | DC_GCFG_DPCK | DC_GCFG_DFCK);
313
gcfg &= ~(unsigned long) DC_GCFG_DCLK_MASK;
314
WRITE_REG32(DC_GENERAL_CFG, gcfg);
316
/* SET THE DOT CLOCK FREQUENCY */
317
/* Mask off the divide by two bit (bit 31) */
318
gfx_set_clock_frequency(pMode->frequency & 0x7FFFFFFF);
320
/* DELAY: WAIT FOR THE PLL TO SETTLE */
321
/* This allows the dot clock frequency that was just set to settle. */
322
gfx_delay_milliseconds(1);
324
/* SET THE "DCLK_MUL" FIELD OF DC_GENERAL_CFG */
325
/* The GX hardware divides the dot clock, so 2x really means that the */
326
/* internal dot clock equals the external dot clock. */
327
if (pMode->frequency & 0x80000000)
332
WRITE_REG32(DC_GENERAL_CFG, gcfg);
334
/* DELAY: WAIT FOR THE ADL TO LOCK */
335
/* This allows the clock generatation within GX to settle. This is */
336
/* needed since some of the register writes that follow require that */
337
/* clock to be present. */
338
gfx_delay_milliseconds(1);
340
/* SET THE GX DISPLAY CONTROLLER PARAMETERS */
341
WRITE_REG32(DC_FB_ST_OFFSET, 0);
342
WRITE_REG32(DC_CB_ST_OFFSET, 0);
343
WRITE_REG32(DC_CURS_ST_OFFSET, 0);
345
/* SET LINE SIZE AND PITCH */
346
/* Flat panels use the current flat panel line size to */
347
/* calculate the pitch, but load the true line size */
348
/* for the mode into the "Frame Buffer Line Size" field */
349
/* of DC_BUF_SIZE. */
353
size = pMode->hactive;
358
/* ONLY PYRAMID SUPPORTS 4K LINE SIZE */
362
/* Graphics acceleration in 16-bit pixel line double modes */
363
/* requires a pitch of 2048. */
364
if ((pMode->flags & GFX_MODE_LINE_DOUBLE) && bpp > 8)
368
if (gfx_cpu_version == GFX_CPU_PYRAMID)
369
pitch = (size <= 2048) ? 2048 : 4096;
374
WRITE_REG32(DC_LINE_DELTA, pitch >> 2);
377
size = pMode->hactive;
382
/* ADD 2 TO SIZE FOR POSSIBLE START ADDRESS ALIGNMENTS */
383
WRITE_REG32(DC_BUF_SIZE, (size >> 3) + 2);
385
/* ALWAYS ENABLE "PANEL" DATA FROM MEDIAGX */
386
/* That is really just the 18 BPP data bus to the companion chip */
387
ocfg = DC_OCFG_PCKE | DC_OCFG_PDEL | DC_OCFG_PDEH;
389
/* SET PIXEL FORMAT */
391
ocfg |= DC_OCFG_8BPP;
395
/* ENABLE TIMING GENERATOR, SYNCS, AND FP DATA */
396
tcfg = DC_TCFG_FPPE | DC_TCFG_HSYE | DC_TCFG_VSYE | DC_TCFG_BLKE |
399
/* SET FIFO PRIORITY, DCLK MULTIPLIER, AND FIFO ENABLE */
400
/* Default 6/5 for FIFO, 2x for DCLK multiplier. */
401
gcfg = (6 << DC_GCFG_DFHPEL_POS) | (5 << DC_GCFG_DFHPSL_POS) | DC_GCFG_DFLE;
403
/* INCREASE FIFO PRIORITY FOR LARGE MODES */
404
if (pMode->hactive == 1280 && pMode->vactive == 1024) {
405
if ((bpp == 8) && (pMode->flags & GFX_MODE_85HZ))
407
(8l << DC_GCFG_DFHPEL_POS) | (7l << DC_GCFG_DFHPSL_POS) |
410
if ((bpp > 8) && (pMode->flags & GFX_MODE_75HZ))
412
(7l << DC_GCFG_DFHPEL_POS) | (6l << DC_GCFG_DFHPSL_POS) |
415
if ((bpp > 8) && (pMode->flags & GFX_MODE_85HZ))
417
(9l << DC_GCFG_DFHPEL_POS) | (8l << DC_GCFG_DFHPSL_POS) |
421
/* SET DOT CLOCK MULTIPLIER */
422
/* Bit 31 of frequency indicates divide frequency by two */
423
if (pMode->frequency & 0x80000000)
424
gcfg |= (1l << DC_GCFG_DCLK_POS);
426
gcfg |= (2l << DC_GCFG_DCLK_POS);
428
/* DIVIDE VIDEO CLOCK */
429
/* CPU core frequencies above 266 MHz will divide the video */
430
/* clock by 4 to ensure that we are running below 150 MHz. */
431
if (gfx_cpu_frequency > 266)
432
gcfg |= DC_GCFG_VCLK_DIV;
434
/* ALWAYS ENABLE VIDEO IN THE DISPLAY CONTROLLER */
435
/* Enabling video at an inopportune momemt can corrupt the DC fetch */
436
/* engine and cause screen artifacts or system hang. */
437
gcfg |= (DC_GCFG_VIDE | DC_GCFG_VRDY);
439
/* SET THE PIXEL AND LINE DOUBLE BITS IF NECESSARY */
440
hactive = pMode->hactive;
441
vactive = pMode->vactive;
443
gfx_pixel_double = 0;
445
if (pMode->flags & GFX_MODE_LINE_DOUBLE) {
446
gcfg |= DC_GCFG_LDBL;
449
/* SET GLOBAL FLAG */
453
if (pMode->flags & GFX_MODE_PIXEL_DOUBLE) {
454
tcfg |= DC_TCFG_PXDB;
457
/* SET GLOBAL FLAG */
458
gfx_pixel_double = 1;
461
/* COMBINE AND SET TIMING VALUES */
463
value = (unsigned long) (hactive - 1) |
464
(((unsigned long) (pMode->htotal - 1)) << 16);
465
WRITE_REG32(DC_H_TIMING_1, value);
466
value = (unsigned long) (pMode->hblankstart - 1) |
467
(((unsigned long) (pMode->hblankend - 1)) << 16);
468
WRITE_REG32(DC_H_TIMING_2, value);
469
value = (unsigned long) (pMode->hsyncstart - 1) |
470
(((unsigned long) (pMode->hsyncend - 1)) << 16);
471
WRITE_REG32(DC_H_TIMING_3, value);
472
WRITE_REG32(DC_FP_H_TIMING, value);
473
value = (unsigned long) (vactive - 1) |
474
(((unsigned long) (pMode->vtotal - 1)) << 16);
475
WRITE_REG32(DC_V_TIMING_1, value);
476
value = (unsigned long) (pMode->vblankstart - 1) |
477
(((unsigned long) (pMode->vblankend - 1)) << 16);
478
WRITE_REG32(DC_V_TIMING_2, value);
479
value = (unsigned long) (pMode->vsyncstart - 1) |
480
(((unsigned long) (pMode->vsyncend - 1)) << 16);
481
WRITE_REG32(DC_V_TIMING_3, value);
482
value = (unsigned long) (pMode->vsyncstart - 2) |
483
(((unsigned long) (pMode->vsyncend - 2)) << 16);
484
WRITE_REG32(DC_FP_V_TIMING, value);
486
WRITE_REG32(DC_OUTPUT_CFG, ocfg);
487
WRITE_REG32(DC_TIMING_CFG, tcfg);
488
gfx_delay_milliseconds(1); /* delay after TIMING_CFG */
489
WRITE_REG32(DC_GENERAL_CFG, gcfg);
491
/* ENABLE FLAT PANEL CENTERING */
492
/* For 640x480 modes displayed with the 9211 within a 800x600 */
493
/* flat panel display, turn on flat panel centering. */
495
if (ModeWidth < PanelWidth) {
496
tcfg = READ_REG32(DC_TIMING_CFG);
497
tcfg = tcfg | DC_TCFG_FCEN;
498
WRITE_REG32(DC_TIMING_CFG, tcfg);
499
gfx_delay_milliseconds(1); /* delay after TIMING_CFG */
503
/* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */
504
gfx_set_display_control(((pMode->flags & GFX_MODE_NEG_HSYNC) ? 1 : 0) |
505
((pMode->flags & GFX_MODE_NEG_VSYNC) ? 2 : 0));
507
/* RESTORE VALUE OF DC_UNLOCK */
508
WRITE_REG32(DC_UNLOCK, unlock);
510
/* ALSO WRITE GP_BLIT_STATUS FOR PITCH AND 8/18 BPP */
511
/* Remember, only Pyramid supports 4K line pitch */
515
if ((gfx_cpu_version == GFX_CPU_PYRAMID) && (pitch > 2048))
516
value |= BC_FB_WIDTH_4096;
517
else if (pitch > 1024)
518
value |= BC_FB_WIDTH_2048;
520
WRITE_REG16(GP_BLIT_STATUS, (unsigned short) value);
522
return GFX_STATUS_OK;
523
} /* end gfx_set_specified_mode() */
525
/*----------------------------------------------------------------------------
526
* GFX_IS_DISPLAY_MODE_SUPPORTED
528
* This routine sets the specified display mode.
530
* Returns the index of the mode if successful and mode returned, -1 if the
531
* mode could not be found.
532
*----------------------------------------------------------------------------
534
#if GFX_DISPLAY_DYNAMIC
536
gu1_is_display_mode_supported(int xres, int yres, int bpp, int hz)
539
gfx_is_display_mode_supported(int xres, int yres, int bpp, int hz)
542
unsigned int mode = 0;
543
unsigned long hz_flag = 0, bpp_flag = 0;
545
/* SET FLAGS TO MATCH REFRESH RATE */
547
hz_flag = GFX_MODE_56HZ;
549
hz_flag = GFX_MODE_60HZ;
551
hz_flag = GFX_MODE_70HZ;
553
hz_flag = GFX_MODE_72HZ;
555
hz_flag = GFX_MODE_75HZ;
557
hz_flag = GFX_MODE_85HZ;
561
/* SET BPP FLAGS TO LIMIT MODE SELECTION */
563
bpp_flag = GFX_MODE_8BPP;
565
bpp_flag = GFX_MODE_15BPP;
567
bpp_flag = GFX_MODE_16BPP;
571
/* ONLY PYRAMID SUPPORTS 4K PITCH */
572
if (gfx_cpu_version != GFX_CPU_PYRAMID && xres > 1024) {
574
return (-1); /* return with mode not found */
577
/* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */
578
for (mode = 0; mode < NUM_GX_DISPLAY_MODES; mode++) {
579
if ((DisplayParams[mode].hactive == (unsigned short) xres) &&
580
(DisplayParams[mode].vactive == (unsigned short) yres) &&
581
(DisplayParams[mode].flags & hz_flag) &&
582
(DisplayParams[mode].flags & bpp_flag)) {
584
/* SET THE DISPLAY CONTROLLER FOR THE SELECTED MODE */
591
/*----------------------------------------------------------------------------
592
* GFX_SET_DISPLAY_MODE
594
* This routine sets the specified display mode.
596
* Returns 1 if successful, 0 if mode could not be set.
597
*----------------------------------------------------------------------------
599
#if GFX_DISPLAY_DYNAMIC
601
gu1_set_display_mode(int xres, int yres, int bpp, int hz)
604
gfx_set_display_mode(int xres, int yres, int bpp, int hz)
609
/* DISABLE FLAT PANEL */
610
/* Flat Panel settings are enabled by the function gfx_set_fixed_timings
611
* and disabled by gfx_set_display_mode. */
614
mode = gfx_is_display_mode_supported(xres, yres, bpp, hz);
616
if (gu1_set_specified_mode(&DisplayParams[mode], bpp) == GFX_STATUS_OK)
622
/*----------------------------------------------------------------------------
623
* GFX_SET_DISPLAY_TIMINGS
625
* This routine sets the display controller mode using the specified timing
626
* values (as opposed to using the tables internal to Durango).
628
* Returns GFX_STATUS_OK on success, GFX_STATUS_ERROR otherwise.
629
*----------------------------------------------------------------------------
631
#if GFX_DISPLAY_DYNAMIC
633
gu1_set_display_timings(unsigned short bpp, unsigned short flags,
634
unsigned short hactive, unsigned short hblankstart,
635
unsigned short hsyncstart, unsigned short hsyncend,
636
unsigned short hblankend, unsigned short htotal,
637
unsigned short vactive, unsigned short vblankstart,
638
unsigned short vsyncstart, unsigned short vsyncend,
639
unsigned short vblankend, unsigned short vtotal,
640
unsigned long frequency)
643
gfx_set_display_timings(unsigned short bpp, unsigned short flags,
644
unsigned short hactive, unsigned short hblankstart,
645
unsigned short hsyncstart, unsigned short hsyncend,
646
unsigned short hblankend, unsigned short htotal,
647
unsigned short vactive, unsigned short vblankstart,
648
unsigned short vsyncstart, unsigned short vsyncend,
649
unsigned short vblankend, unsigned short vtotal,
650
unsigned long frequency)
653
/* SET MODE STRUCTURE WITH SPECIFIED VALUES */
655
gfx_display_mode.flags = 0;
657
gfx_display_mode.flags |= GFX_MODE_NEG_HSYNC;
659
gfx_display_mode.flags |= GFX_MODE_NEG_VSYNC;
661
gfx_display_mode.flags |= GFX_MODE_LOCK_TIMING;
662
gfx_display_mode.hactive = hactive;
663
gfx_display_mode.hblankstart = hblankstart;
664
gfx_display_mode.hsyncstart = hsyncstart;
665
gfx_display_mode.hsyncend = hsyncend;
666
gfx_display_mode.hblankend = hblankend;
667
gfx_display_mode.htotal = htotal;
668
gfx_display_mode.vactive = vactive;
669
gfx_display_mode.vblankstart = vblankstart;
670
gfx_display_mode.vsyncstart = vsyncstart;
671
gfx_display_mode.vsyncend = vsyncend;
672
gfx_display_mode.vblankend = vblankend;
673
gfx_display_mode.vtotal = vtotal;
674
gfx_display_mode.frequency = frequency;
676
/* CALL ROUTINE TO SET MODE */
677
return (gu1_set_specified_mode(&gfx_display_mode, bpp));
680
/*----------------------------------------------------------------------------
683
* This routine sets the display controller vertical total to
684
* "vtotal". As a side effect it also sets vertical blank end.
685
* It should be used when only this value needs to be changed,
686
* due to speed considerations.
688
* Note: it is the caller's responsibility to make sure that
689
* a legal vtotal is used, i.e. that "vtotal" is greater than or
690
* equal to vsync end.
693
*----------------------------------------------------------------------------
695
#if GFX_DISPLAY_DYNAMIC
697
gu1_set_vtotal(unsigned short vtotal)
700
gfx_set_vtotal(unsigned short vtotal)
703
unsigned long unlock, tcfg, timing1, timing2;
705
/* UNLOCK THE DISPLAY CONTROLLER REGISTERS */
706
unlock = READ_REG32(DC_UNLOCK);
707
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
709
/* READ THE CURRENT GX VALUES */
710
tcfg = READ_REG32(DC_TIMING_CFG);
711
timing1 = READ_REG32(DC_V_TIMING_1);
712
timing2 = READ_REG32(DC_V_TIMING_2);
714
/* DISABLE THE TIMING GENERATOR */
715
WRITE_REG32(DC_TIMING_CFG, tcfg & ~(unsigned long) DC_TCFG_TGEN);
717
/* WRITE NEW TIMING VALUES */
718
WRITE_REG32(DC_V_TIMING_1,
719
(timing1 & 0xffff) | (unsigned long) (vtotal - 1) << 16);
720
WRITE_REG32(DC_V_TIMING_2,
721
(timing2 & 0xffff) | (unsigned long) (vtotal - 1) << 16);
723
/* RESTORE GX VALUES */
724
WRITE_REG32(DC_TIMING_CFG, tcfg);
725
WRITE_REG32(DC_UNLOCK, unlock);
730
/*---------------------------------------------------------------------------
731
* gfx_set_display_pitch
733
* This routine sets the pitch of the frame buffer to the specified value.
734
*---------------------------------------------------------------------------
736
#if GFX_DISPLAY_DYNAMIC
738
gu1_set_display_pitch(unsigned short pitch)
741
gfx_set_display_pitch(unsigned short pitch)
744
unsigned long value = 0;
745
unsigned long lock = READ_REG32(DC_UNLOCK);
747
value = READ_REG32(DC_LINE_DELTA) & 0xFFFFF000;
748
value |= (pitch >> 2);
749
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
750
WRITE_REG32(DC_LINE_DELTA, value);
751
WRITE_REG32(DC_UNLOCK, lock);
753
/* ALSO UPDATE PITCH IN GRAPHICS ENGINE */
754
/* Pyramid alone supports 4K line pitch */
755
value = (unsigned long) READ_REG16(GP_BLIT_STATUS);
756
value &= ~(BC_FB_WIDTH_2048 | BC_FB_WIDTH_4096);
758
if ((gfx_cpu_version == GFX_CPU_PYRAMID) && (pitch > 2048))
759
value |= BC_FB_WIDTH_4096;
761
else if (pitch > 1024)
762
value |= BC_FB_WIDTH_2048;
764
WRITE_REG16(GP_BLIT_STATUS, (unsigned short) value);
768
/*---------------------------------------------------------------------------
769
* gfx_set_display_offset
771
* This routine sets the start address of the frame buffer. It is
772
* typically used to pan across a virtual desktop (frame buffer larger than
773
* the displayed screen) or to flip the display between multiple buffers.
774
*---------------------------------------------------------------------------
776
#if GFX_DISPLAY_DYNAMIC
778
gu1_set_display_offset(unsigned long offset)
781
gfx_set_display_offset(unsigned long offset)
784
/* UPDATE FRAME BUFFER OFFSET */
788
lock = READ_REG32(DC_UNLOCK);
789
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
791
/* START ADDRESS EFFECTS DISPLAY COMPRESSION */
792
/* Disable compression for non-zero start addresss values. */
793
/* Enable compression if offset is zero and comression is intended to */
794
/* be enabled from a previous call to "gfx_set_compression_enable". */
795
/* Compression should be disabled BEFORE the offset is changed */
796
/* and enabled AFTER the offset is changed. */
798
WRITE_REG32(DC_FB_ST_OFFSET, offset);
799
if (gfx_compression_enabled) {
800
/* WAIT FOR THE OFFSET TO BE LATCHED */
801
gfx_wait_vertical_blank();
802
gu1_enable_compression();
806
/* ONLY DISABLE COMPRESSION ONCE */
807
if (gfx_compression_active)
808
gu1_disable_compression();
810
WRITE_REG32(DC_FB_ST_OFFSET, offset);
813
WRITE_REG32(DC_UNLOCK, lock);
816
/*---------------------------------------------------------------------------
817
* gfx_set_display_palette_entry
819
* This routine sets an palette entry in the display controller.
820
* A 32-bit X:R:G:B value.
821
*---------------------------------------------------------------------------
823
#if GFX_DISPLAY_DYNAMIC
825
gu1_set_display_palette_entry(unsigned long index, unsigned long palette)
828
gfx_set_display_palette_entry(unsigned long index, unsigned long palette)
834
return GFX_STATUS_BAD_PARAMETER;
836
WRITE_REG32(DC_PAL_ADDRESS, index);
837
data = ((palette >> 2) & 0x0003F) |
838
((palette >> 4) & 0x00FC0) | ((palette >> 6) & 0x3F000);
839
WRITE_REG32(DC_PAL_DATA, data);
844
/*---------------------------------------------------------------------------
845
* gfx_set_display_palette
847
* This routine sets the entire palette in the display controller.
848
* A pointer is provided to a 256 entry table of 32-bit X:R:G:B values.
851
* Due to SC1200 Issue #748 (in Notes DB) this function should be called only
852
* when DCLK is active, i.e PLL is already powered up and genlock is not
854
*---------------------------------------------------------------------------
856
#if GFX_DISPLAY_DYNAMIC
858
gu1_set_display_palette(unsigned long *palette)
861
gfx_set_display_palette(unsigned long *palette)
864
unsigned long data, i;
866
WRITE_REG32(DC_PAL_ADDRESS, 0);
868
for (i = 0; i < 256; i++) {
869
/* CONVERT 24 BPP COLOR DATA TO 18 BPP COLOR DATA */
870
data = ((palette[i] >> 2) & 0x0003F) |
871
((palette[i] >> 4) & 0x00FC0) | ((palette[i] >> 6) & 0x3F000);
872
WRITE_REG32(DC_PAL_DATA, data);
878
/*---------------------------------------------------------------------------
879
* gfx_set_cursor_enable
881
* This routine enables or disables the hardware cursor.
883
* WARNING: The cusrsor start offset must be set by setting the cursor
884
* position before calling this routine to assure that memory reads do not
885
* go past the end of graphics memory (this can hang GXm).
886
*---------------------------------------------------------------------------
888
#if GFX_DISPLAY_DYNAMIC
890
gu1_set_cursor_enable(int enable)
893
gfx_set_cursor_enable(int enable)
896
unsigned long unlock, gcfg;
898
/* SET OR CLEAR CURSOR ENABLE BIT */
899
unlock = READ_REG32(DC_UNLOCK);
900
gcfg = READ_REG32(DC_GENERAL_CFG);
902
gcfg |= DC_GCFG_CURE;
904
gcfg &= ~(DC_GCFG_CURE);
906
/* WRITE NEW REGISTER VALUE */
907
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
908
WRITE_REG32(DC_GENERAL_CFG, gcfg);
909
WRITE_REG32(DC_UNLOCK, unlock);
912
/*---------------------------------------------------------------------------
913
* gfx_set_cursor_colors
915
* This routine sets the colors of the hardware cursor.
918
* Due to SC1200 Issue #748 (in Notes DB) this function should be called only
919
* when DCLK is active, i.e PLL is already powered up.
920
*---------------------------------------------------------------------------
922
#if GFX_DISPLAY_DYNAMIC
924
gu1_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor)
927
gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor)
932
/* If genlock is enabled DCLK might be disabled in vertical blank. */
933
/* Due to SC1200 Issue #748 in Notes DB this would fail the cursor color settings */
934
/* So Wait for vertical blank to end */
937
if (gfx_test_timing_active())
938
while ((gfx_get_vline()) > gfx_get_vactive());
940
/* SET CURSOR COLORS */
941
WRITE_REG32(DC_PAL_ADDRESS, 0x100);
942
value = ((bkcolor & 0x000000FC) >> 2) |
943
((bkcolor & 0x0000FC00) >> (2 + 8 - 6)) |
944
((bkcolor & 0x00FC0000) >> (2 + 16 - 12));
945
WRITE_REG32(DC_PAL_DATA, value);
946
value = ((fgcolor & 0x000000FC) >> 2) |
947
((fgcolor & 0x0000FC00) >> (2 + 8 - 6)) |
948
((fgcolor & 0x00FC0000) >> (2 + 16 - 12));
949
WRITE_REG32(DC_PAL_DATA, value);
952
/*---------------------------------------------------------------------------
953
* gfx_set_cursor_position
955
* This routine sets the position of the hardware cusror. The starting
956
* offset of the cursor buffer must be specified so that the routine can
957
* properly clip scanlines if the cursor is off the top of the screen.
958
*---------------------------------------------------------------------------
960
#if GFX_DISPLAY_DYNAMIC
962
gu1_set_cursor_position(unsigned long memoffset,
963
unsigned short xpos, unsigned short ypos,
964
unsigned short xhotspot, unsigned short yhotspot)
967
gfx_set_cursor_position(unsigned long memoffset,
968
unsigned short xpos, unsigned short ypos,
969
unsigned short xhotspot, unsigned short yhotspot)
972
unsigned long unlock;
978
/* SUPPORT CURSOR IN EMULATED VGA MODES */
979
/* Timings are for twice the resolution */
980
if (gfx_pixel_double)
986
x = (short) xpos - (short) xhotspot;
987
y = (short) ypos - (short) yhotspot;
1004
memoffset += (unsigned long) yoffset << 3;
1007
if ((ModeWidth > PanelWidth) || (ModeHeight > PanelHeight)) {
1008
gfx_enable_panning(xpos, ypos);
1009
x = x - (short) panelLeft;
1010
y = y - (short) panelTop;
1014
/* SET CURSOR POSITION */
1015
unlock = READ_REG32(DC_UNLOCK);
1016
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1017
WRITE_REG32(DC_CURS_ST_OFFSET, memoffset);
1018
WRITE_REG32(DC_CURSOR_X, (unsigned long) x |
1019
(((unsigned long) xoffset) << 11));
1020
WRITE_REG32(DC_CURSOR_Y, (unsigned long) y |
1021
(((unsigned long) yoffset) << 11));
1022
WRITE_REG32(DC_UNLOCK, unlock);
1025
/*---------------------------------------------------------------------------
1026
* gfx_set_cursor_shape32
1028
* This routine loads 32x32 cursor data into the specified location in
1030
*---------------------------------------------------------------------------
1032
#if GFX_DISPLAY_DYNAMIC
1034
gu1_set_cursor_shape32(unsigned long memoffset,
1035
unsigned long *andmask, unsigned long *xormask)
1038
gfx_set_cursor_shape32(unsigned long memoffset,
1039
unsigned long *andmask, unsigned long *xormask)
1043
unsigned long value;
1045
for (i = 0; i < 32; i++) {
1046
/* CONVERT TO 16 BITS AND MASK, 16 BITS XOR MASK PER DWORD */
1047
value = (andmask[i] & 0xFFFF0000) | (xormask[i] >> 16);
1048
WRITE_FB32(memoffset, value);
1050
value = (andmask[i] << 16) | (xormask[i] & 0x0000FFFF);
1051
WRITE_FB32(memoffset, value);
1056
/*---------------------------------------------------------------------------
1057
* gu1_enable_compression
1059
* This is a private routine to this module (not exposed in the Durango API).
1060
* It enables display compression.
1061
*---------------------------------------------------------------------------
1064
gu1_enable_compression(void)
1067
unsigned long unlock, gcfg, offset;
1069
/* DO NOT ENABLE IF START ADDRESS IS NOT ZERO */
1070
offset = READ_REG32(DC_FB_ST_OFFSET) & 0x003FFFFF;
1074
/* DO NOT ENABLE IF WE ARE WITHIN AN EMULATED VGA MODE */
1075
if (gfx_line_double || gfx_pixel_double)
1078
/* SET GLOBAL INDICATOR */
1079
gfx_compression_active = 1;
1081
/* CLEAR DIRTY/VALID BITS IN MEMORY CONTROLLER */
1082
/* Software is required to do this before enabling compression. */
1083
/* Don't want controller to think that old lines are still valid. */
1084
for (i = 0; i < 1024; i++) {
1085
WRITE_REG32(MC_DR_ADD, i);
1086
WRITE_REG32(MC_DR_ACC, 0);
1089
/* TURN ON COMPRESSION CONTROL BITS */
1090
unlock = READ_REG32(DC_UNLOCK);
1091
gcfg = READ_REG32(DC_GENERAL_CFG);
1092
gcfg |= DC_GCFG_CMPE | DC_GCFG_DECE;
1093
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1094
WRITE_REG32(DC_GENERAL_CFG, gcfg);
1095
WRITE_REG32(DC_UNLOCK, unlock);
1098
/*---------------------------------------------------------------------------
1099
* gu1_disable_compression
1101
* This is a private routine to this module (not exposed in the Durango API).
1102
* It disables display compression.
1103
*---------------------------------------------------------------------------
1106
gu1_disable_compression(void)
1108
unsigned long unlock, gcfg;
1110
/* SET GLOBAL INDICATOR */
1111
gfx_compression_active = 0;
1113
/* TURN OFF COMPRESSION CONTROL BITS */
1114
unlock = READ_REG32(DC_UNLOCK);
1115
gcfg = READ_REG32(DC_GENERAL_CFG);
1116
gcfg &= ~(DC_GCFG_CMPE | DC_GCFG_DECE);
1117
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1118
WRITE_REG32(DC_GENERAL_CFG, gcfg);
1119
WRITE_REG32(DC_UNLOCK, unlock);
1122
/*---------------------------------------------------------------------------
1123
* gfx_set_compression_enable
1125
* This routine enables or disables display compression.
1126
*---------------------------------------------------------------------------
1128
#if GFX_DISPLAY_DYNAMIC
1130
gu1_set_compression_enable(int enable)
1133
gfx_set_compression_enable(int enable)
1136
/* SET GLOBAL VARIABLE FOR INTENDED STATE */
1137
/* Compression can only be enabled for non-zero start address values. */
1138
/* Keep state to enable compression on start address changes. */
1139
gfx_compression_enabled = enable;
1141
gu1_enable_compression();
1143
gu1_disable_compression();
1148
/*---------------------------------------------------------------------------
1149
* gfx_set_compression_offset
1151
* This routine sets the base offset for the compression buffer.
1152
*---------------------------------------------------------------------------
1154
#if GFX_DISPLAY_DYNAMIC
1156
gu1_set_compression_offset(unsigned long offset)
1159
gfx_set_compression_offset(unsigned long offset)
1164
/* MUST BE 16-BYTE ALIGNED FOR GXLV */
1168
/* SET REGISTER VALUE */
1169
lock = READ_REG32(DC_UNLOCK);
1170
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1171
WRITE_REG32(DC_CB_ST_OFFSET, offset);
1172
WRITE_REG32(DC_UNLOCK, lock);
1176
/*---------------------------------------------------------------------------
1177
* gfx_set_compression_pitch
1179
* This routine sets the pitch, in bytes, of the compression buffer.
1180
*---------------------------------------------------------------------------
1182
#if GFX_DISPLAY_DYNAMIC
1184
gu1_set_compression_pitch(unsigned short pitch)
1187
gfx_set_compression_pitch(unsigned short pitch)
1190
unsigned long lock, line_delta;
1192
/* SET REGISTER VALUE */
1193
lock = READ_REG32(DC_UNLOCK);
1194
line_delta = READ_REG32(DC_LINE_DELTA) & 0xFF800FFF;
1195
line_delta |= ((unsigned long) pitch << 10l) & 0x007FF000;
1196
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1197
WRITE_REG32(DC_LINE_DELTA, line_delta);
1198
WRITE_REG32(DC_UNLOCK, lock);
1202
/*---------------------------------------------------------------------------
1203
* gfx_set_compression_size
1205
* This routine sets the line size of the compression buffer, which is the
1206
* maximum number of bytes allowed to store a compressed line.
1207
*---------------------------------------------------------------------------
1209
#if GFX_DISPLAY_DYNAMIC
1211
gu1_set_compression_size(unsigned short size)
1214
gfx_set_compression_size(unsigned short size)
1217
unsigned long lock, buf_size;
1219
/* SUBTRACT 16 FROM SIZE */
1220
/* The display controller will actually write */
1221
/* 2 extra QWords. So, if we assume that "size" */
1222
/* refers to the allocated size, we must subtract */
1226
/* SET REGISTER VALUE */
1227
lock = READ_REG32(DC_UNLOCK);
1228
buf_size = READ_REG32(DC_BUF_SIZE) & 0xFFFF01FF;
1229
buf_size |= (((size >> 2) + 1) & 0x7F) << 9;
1230
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1231
WRITE_REG32(DC_BUF_SIZE, buf_size);
1232
WRITE_REG32(DC_UNLOCK, lock);
1236
/*---------------------------------------------------------------------------
1237
* gfx_set_display_video_enable (PRIVATE ROUTINE - NOT PART OF API)
1239
* This routine enables/disables video on GX.
1240
*---------------------------------------------------------------------------
1242
#if GFX_DISPLAY_DYNAMIC
1244
gu1_set_display_video_enable(int enable)
1247
gfx_set_display_video_enable(int enable)
1250
unsigned long lock, gcfg, buf_size;
1252
lock = READ_REG32(DC_UNLOCK);
1253
gcfg = READ_REG32(DC_GENERAL_CFG);
1254
buf_size = READ_REG32(DC_BUF_SIZE);
1256
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1258
vid_enabled = enable;
1260
/* SET THE BUFFER SIZE TO A NON-ZERO VALUE ONLY WHEN */
1261
/* ENABLING VIDEO */
1263
gcfg |= (DC_GCFG_VIDE | DC_GCFG_VRDY);
1264
WRITE_REG32(DC_GENERAL_CFG, gcfg);
1266
WRITE_REG32(DC_BUF_SIZE, (buf_size & 0x0000FFFFl) | vid_buf_size);
1268
/* CLEAR THE VIDEO BUFFER SIZE WHEN DISABLING VIDEO */
1270
gcfg &= ~(DC_GCFG_VIDE);
1271
WRITE_REG32(DC_GENERAL_CFG, gcfg);
1273
vid_buf_size = buf_size & 0xFFFF0000l;
1274
WRITE_REG32(DC_BUF_SIZE, buf_size & 0x0000FFFFl);
1277
WRITE_REG32(DC_UNLOCK, lock);
1281
/*---------------------------------------------------------------------------
1282
* gfx_set_display_video_size (PRIVATE ROUTINE - NOT PART OF API)
1284
* This routine is called by "gfx_set_video_size". It abstracts the
1285
* version of the display controller from the video overlay routines.
1286
*---------------------------------------------------------------------------
1288
#if GFX_DISPLAY_DYNAMIC
1290
gu1_set_display_video_size(unsigned short width, unsigned short height)
1293
gfx_set_display_video_size(unsigned short width, unsigned short height)
1296
unsigned long lock, size, value;
1298
size = (unsigned long) (width << 1) * (unsigned long) height;
1300
/* STORE THE VIDEO BUFFER SIZE AS A GLOBAL */
1301
vid_buf_size = ((size + 63) >> 6) << 16;
1303
lock = READ_REG32(DC_UNLOCK);
1304
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1305
value = READ_REG32(DC_BUF_SIZE) & 0x0000FFFF;
1306
value |= vid_buf_size;
1307
WRITE_REG32(DC_BUF_SIZE, value);
1308
WRITE_REG32(DC_UNLOCK, lock);
1311
/*---------------------------------------------------------------------------
1312
* gfx_set_display_video_offset (PRIVATE ROUTINE - NOT PART OF API)
1314
* This routine is called by "gfx_set_video_offset". It abstracts the
1315
* version of the display controller from the video overlay routines.
1316
*---------------------------------------------------------------------------
1318
#if GFX_DISPLAY_DYNAMIC
1320
gu1_set_display_video_offset(unsigned long offset)
1323
gfx_set_display_video_offset(unsigned long offset)
1328
lock = READ_REG32(DC_UNLOCK);
1329
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1330
offset &= 0x003FFFFF;
1331
WRITE_REG32(DC_VID_ST_OFFSET, offset);
1332
WRITE_REG32(DC_UNLOCK, lock);
1335
/*---------------------------------------------------------------------------
1336
* gfx_set_display_priority_high
1338
* This routine controls the x-bus round robin arbitration mechanism.
1339
* When enable is TRUE, graphics pipeline requests and non-critical display
1340
* controller requests are arbitrated at the same priority as processor
1341
* requests. When FALSE processor requests are arbitrated at a higher priority
1342
*---------------------------------------------------------------------------
1344
#if GFX_DISPLAY_DYNAMIC
1346
gu1_set_display_priority_high(int enable)
1349
gfx_set_display_priority_high(int enable)
1352
unsigned long lock, control;
1354
lock = READ_REG32(DC_UNLOCK);
1355
control = READ_REG32(MC_MEM_CNTRL1);
1356
WRITE_REG32(DC_UNLOCK, DC_UNLOCK_VALUE);
1358
control |= MC_XBUSARB;
1360
control &= ~(MC_XBUSARB);
1361
WRITE_REG32(MC_MEM_CNTRL1, control);
1362
WRITE_REG32(DC_UNLOCK, lock);
1366
/*---------------------------------------------------------------------------
1367
* gfx_test_timing_active
1368
*---------------------------------------------------------------------------
1370
#if GFX_DISPLAY_DYNAMIC
1372
gu1_test_timing_active(void)
1375
gfx_test_timing_active(void)
1378
if (READ_REG32(DC_TIMING_CFG) & DC_TCFG_TGEN)
1384
/*---------------------------------------------------------------------------
1385
* gfx_test_vertical_active
1386
*---------------------------------------------------------------------------
1388
#if GFX_DISPLAY_DYNAMIC
1390
gu1_test_vertical_active(void)
1393
gfx_test_vertical_active(void)
1396
if (READ_REG32(DC_TIMING_CFG) & DC_TCFG_VNA)
1402
/*---------------------------------------------------------------------------
1403
* gfx_wait_vertical_blank
1404
*---------------------------------------------------------------------------
1406
#if GFX_DISPLAY_DYNAMIC
1408
gu1_wait_vertical_blank(void)
1411
gfx_wait_vertical_blank(void)
1414
if (gfx_test_timing_active()) {
1415
while (!gfx_test_vertical_active());
1416
while (gfx_test_vertical_active());
1422
/*---------------------------------------------------------------------------
1423
* gfx_enable_panning
1425
* This routine enables the panning when the Mode is bigger than the panel
1427
*---------------------------------------------------------------------------
1429
#if GFX_DISPLAY_DYNAMIC
1431
gu1_enable_panning(int x, int y)
1434
gfx_enable_panning(int x, int y)
1437
unsigned long modeBytesPerPixel;
1438
unsigned long modeBytesPerScanline = 0;
1439
unsigned long startAddress = 0;
1441
modeBytesPerPixel = (gbpp + 7) / 8;
1442
modeBytesPerScanline =
1443
(((ModeWidth + 1023) / 1024) * 1024) * modeBytesPerPixel;
1445
/* TEST FOR NO-WORK */
1446
if (x >= DeltaX && (unsigned short) x < (PanelWidth + DeltaX) &&
1447
y >= DeltaY && (unsigned short) y < (PanelHeight + DeltaY))
1450
/* ADJUST PANNING VARIABLES WHEN CURSOR EXCEEDS BOUNDARY */
1451
/* Test the boundary conditions for each coordinate and update */
1452
/* all variables and the starting offset accordingly. */
1455
else if ((unsigned short) x >= (DeltaX + PanelWidth))
1456
DeltaX = x - PanelWidth + 1;
1460
else if ((unsigned short) y >= (DeltaY + PanelHeight))
1461
DeltaY = y - PanelHeight + 1;
1463
/* CALCULATE THE START OFFSET */
1465
(DeltaX * modeBytesPerPixel) + (DeltaY * modeBytesPerScanline);
1467
gfx_set_display_offset(startAddress);
1469
/* SET PANEL COORDINATES */
1470
/* Panel's x position must be DWORD aligned */
1472
panelLeft = DeltaX * modeBytesPerPixel;
1475
panelLeft = (panelLeft & 0xFFFFFFFC) + 4;
1477
panelLeft /= modeBytesPerPixel;
1481
/*---------------------------------------------------------------------------
1482
* gfx_set_fixed_timings
1483
*---------------------------------------------------------------------------
1485
#if GFX_DISPLAY_DYNAMIC
1487
gu1_set_fixed_timings(int panelResX, int panelResY, unsigned short width,
1488
unsigned short height, unsigned short bpp)
1491
gfx_set_fixed_timings(int panelResX, int panelResY, unsigned short width,
1492
unsigned short height, unsigned short bpp)
1498
ModeHeight = height;
1499
PanelWidth = (unsigned short) panelResX;
1500
PanelHeight = (unsigned short) panelResY;
1503
/* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */
1504
for (mode = 0; mode < NUM_FIXED_TIMINGS_MODES; mode++) {
1505
if ((FixedParams[mode].xres == width) &&
1506
(FixedParams[mode].yres == height) &&
1507
(FixedParams[mode].panelresx == panelResX) &&
1508
(FixedParams[mode].panelresy == panelResY)) {
1510
/* SET THE 92xx FOR THE SELECTED MODE */
1511
FIXEDTIMINGS *fmode = &FixedParams[mode];
1513
gfx_set_display_timings(bpp, 3, fmode->hactive,
1514
fmode->hblankstart, fmode->hsyncstart,
1515
fmode->hsyncend, fmode->hblankend,
1516
fmode->htotal, fmode->vactive,
1517
fmode->vblankstart, fmode->vsyncstart,
1518
fmode->vsyncend, fmode->vblankend,
1519
fmode->vtotal, fmode->frequency);
1528
/*---------------------------------------------------------------------------
1529
* gfx_set_panel_present
1530
*---------------------------------------------------------------------------
1532
#if GFX_DISPLAY_DYNAMIC
1534
gu1_set_panel_present(int panelResX, int panelResY, unsigned short width,
1535
unsigned short height, unsigned short bpp)
1538
gfx_set_panel_present(int panelResX, int panelResY, unsigned short width,
1539
unsigned short height, unsigned short bpp)
1543
/* 16BPP is the default. */
1544
if (bpp != 8 && bpp != 15 && bpp != 16)
1547
/* RECORD PANEL PARAMETERS */
1548
/* This routine does not touch any panel timings. It is used when custom
1549
* panel settings are set up in advance by the BIOS or an application, but
1550
* the application still requires access to other panel functionality
1551
* provided by Durango (i.e. panning)
1555
ModeHeight = height;
1556
PanelWidth = (unsigned short) panelResX;
1557
PanelHeight = (unsigned short) panelResY;
1561
/* PROGRAM THE BPP IN THE DISPLAY CONTROLLER */
1562
gfx_set_display_bpp(bpp);
1564
return (GFX_STATUS_OK);
1567
/*-----------------------------------------------------------------------*
1568
* THE FOLLOWING READ ROUTINES ARE ALWAYS INCLUDED: *
1569
* gfx_get_hsync_end, gfx_get_htotal, gfx_get_vsync_end, gfx_get_vtotal *
1570
* are used by the video overlay routines. *
1572
* gfx_get_vline and gfx_vactive are used to prevent an issue for the *
1575
* The others are part of the Durango API. *
1576
*-----------------------------------------------------------------------*/
1578
/*---------------------------------------------------------------------------
1579
* gfx_get_display_pitch
1581
* This routine returns the current pitch of the frame buffer, in bytes.
1582
*---------------------------------------------------------------------------
1584
#if GFX_DISPLAY_DYNAMIC
1586
gu1_get_display_pitch(void)
1589
gfx_get_display_pitch(void)
1592
unsigned long value;
1594
if (gfx_cpu_version == GFX_CPU_PYRAMID) {
1595
/* Pyramid update for 4KB line pitch */
1596
value = (READ_REG32(DC_LINE_DELTA) & 0x07FF) << 2;
1599
value = (READ_REG32(DC_LINE_DELTA) & 0x03FF) << 2;
1602
return ((unsigned short) value);
1605
/*----------------------------------------------------------------------------
1606
* GFX_GET_DISPLAY_DETAILS
1608
* This routine gets the specified display mode.
1610
* Returns 1 if successful, 0 if mode could not be get.
1611
*----------------------------------------------------------------------------
1613
#if GFX_DISPLAY_DYNAMIC
1615
gu1_get_display_details(unsigned int mode, int *xres, int *yres, int *hz)
1618
gfx_get_display_details(unsigned int mode, int *xres, int *yres, int *hz)
1621
if (mode < NUM_GX_DISPLAY_MODES) {
1622
if (DisplayParams[mode].flags & GFX_MODE_56HZ)
1624
else if (DisplayParams[mode].flags & GFX_MODE_60HZ)
1626
else if (DisplayParams[mode].flags & GFX_MODE_70HZ)
1628
else if (DisplayParams[mode].flags & GFX_MODE_72HZ)
1630
else if (DisplayParams[mode].flags & GFX_MODE_75HZ)
1632
else if (DisplayParams[mode].flags & GFX_MODE_85HZ)
1635
*xres = DisplayParams[mode].hactive;
1636
*yres = DisplayParams[mode].vactive;
1643
/*----------------------------------------------------------------------------
1644
* GFX_GET_DISPLAY_MODE_COUNT
1646
* Returns number of modes supported.
1647
*----------------------------------------------------------------------------
1649
#if GFX_DISPLAY_DYNAMIC
1651
gu1_get_display_mode_count(void)
1654
gfx_get_display_mode_count(void)
1657
return (NUM_GX_DISPLAY_MODES);
1660
/*----------------------------------------------------------------------------
1661
* gfx_get_frame_buffer_line_size
1663
* Returns the current frame buffer line size, in bytes
1664
*----------------------------------------------------------------------------
1666
#if GFX_DISPLAY_DYNAMIC
1668
gu1_get_frame_buffer_line_size(void)
1671
gfx_get_frame_buffer_line_size(void)
1674
return ((READ_REG32(DC_BUF_SIZE) & 0x1FF) << 3);
1677
/*----------------------------------------------------------------------------
1678
* gfx_mode_frequency_supported
1680
* This routine examines if the requested mode with pixel frequency is supported.
1682
* Returns >0 if successful , <0 if freq. could not be found and matched.
1683
*----------------------------------------------------------------------------
1685
#if GFX_DISPLAY_DYNAMIC
1687
gu1_mode_frequency_supported(int xres, int yres, int bpp,
1688
unsigned long frequency)
1691
gfx_mode_frequency_supported(int xres, int yres, int bpp,
1692
unsigned long frequency)
1696
unsigned long value;
1697
unsigned long bpp_flag = 0;
1699
bpp_flag = GFX_MODE_8BPP;
1701
bpp_flag = GFX_MODE_16BPP;
1703
for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) {
1704
if ((DisplayParams[index].hactive == (unsigned short) xres) &&
1705
(DisplayParams[index].vactive == (unsigned short) yres) &&
1706
(DisplayParams[index].flags & bpp_flag) &&
1707
(DisplayParams[index].frequency == frequency)) {
1710
value = DisplayParams[index].flags;
1712
if (value & GFX_MODE_56HZ)
1714
else if (value & GFX_MODE_60HZ)
1716
else if (value & GFX_MODE_70HZ)
1718
else if (value & GFX_MODE_72HZ)
1720
else if (value & GFX_MODE_75HZ)
1722
else if (value & GFX_MODE_85HZ)
1731
/*----------------------------------------------------------------------------
1732
* gfx_refreshrate_from_frequency
1734
* This routine maps the frequency to close match refresh rate
1735
*----------------------------------------------------------------------------
1737
#if GFX_DISPLAY_DYNAMIC
1739
gu1_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz,
1740
unsigned long frequency)
1743
gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz,
1744
unsigned long frequency)
1747
unsigned int index, closematch = 0;
1748
unsigned long value;
1749
unsigned long bpp_flag = 0;
1754
bpp_flag = GFX_MODE_8BPP;
1756
bpp_flag = GFX_MODE_16BPP;
1758
/* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */
1759
/* Search the table for the closest frequency (16.16 format). */
1761
for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) {
1762
if ((DisplayParams[index].htotal == (unsigned short) xres) &&
1763
(DisplayParams[index].vtotal == (unsigned short) yres) &&
1764
(DisplayParams[index].flags & bpp_flag)) {
1765
diff = (long) frequency - (long) DisplayParams[index].frequency;
1776
value = DisplayParams[closematch].flags;
1778
if (value & GFX_MODE_56HZ)
1780
else if (value & GFX_MODE_60HZ)
1782
else if (value & GFX_MODE_70HZ)
1784
else if (value & GFX_MODE_72HZ)
1786
else if (value & GFX_MODE_75HZ)
1788
else if (value & GFX_MODE_85HZ)
1794
/*----------------------------------------------------------------------------
1795
* gfx_refreshrate_from_mode
1797
* This routine is identical to the gfx_get_refreshrate_from_frequency,
1798
* except that the active timing values are compared instead of the total
1799
* values. Some modes (such as 70Hz and 72Hz) may be confused in this routine
1800
*----------------------------------------------------------------------------
1802
#if GFX_DISPLAY_DYNAMIC
1804
gu1_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz,
1805
unsigned long frequency)
1808
gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz,
1809
unsigned long frequency)
1812
unsigned int index, closematch = 0;
1813
unsigned long value;
1814
unsigned long bpp_flag = 0;
1819
bpp_flag = GFX_MODE_8BPP;
1821
bpp_flag = GFX_MODE_16BPP;
1823
/* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */
1824
/* Search the table for the closest frequency (16.16 format). */
1826
for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) {
1827
if ((DisplayParams[index].hactive == (unsigned short) xres) &&
1828
(DisplayParams[index].vactive == (unsigned short) yres) &&
1829
(DisplayParams[index].flags & bpp_flag)) {
1830
diff = (long) frequency - (long) DisplayParams[index].frequency;
1841
value = DisplayParams[closematch].flags;
1843
if (value & GFX_MODE_56HZ)
1845
else if (value & GFX_MODE_60HZ)
1847
else if (value & GFX_MODE_70HZ)
1849
else if (value & GFX_MODE_72HZ)
1851
else if (value & GFX_MODE_75HZ)
1853
else if (value & GFX_MODE_85HZ)
1859
/*----------------------------------------------------------------------------
1860
* gfx_get_frequency_from_refreshrate
1862
* This routine maps the refresh rate to the closest matching PLL frequency.
1863
*----------------------------------------------------------------------------
1865
#if GFX_DISPLAY_DYNAMIC
1867
gu1_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz,
1871
gfx_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz,
1877
unsigned long hz_flag = 0;
1878
unsigned long bpp_flag = 0;
1883
hz_flag = GFX_MODE_56HZ;
1885
hz_flag = GFX_MODE_60HZ;
1887
hz_flag = GFX_MODE_70HZ;
1889
hz_flag = GFX_MODE_72HZ;
1891
hz_flag = GFX_MODE_75HZ;
1893
hz_flag = GFX_MODE_85HZ;
1895
bpp_flag = GFX_MODE_8BPP;
1897
bpp_flag = GFX_MODE_16BPP;
1899
/* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */
1901
for (index = 0; index < NUM_GX_DISPLAY_MODES; index++) {
1902
if ((DisplayParams[index].hactive == (unsigned short) xres) &&
1903
(DisplayParams[index].vactive == (unsigned short) yres) &&
1904
(DisplayParams[index].flags & bpp_flag) &&
1905
(DisplayParams[index].flags & hz_flag)) {
1906
*frequency = DisplayParams[index].frequency;
1913
/*---------------------------------------------------------------------------
1914
* gfx_get_max_supported_pixel_clock
1916
* This routine returns the maximum recommended speed for the pixel clock. The
1917
* return value is an integer of the format xxxyyy, where xxx.yyy is the maximum
1918
* floating point pixel clock speed.
1919
*---------------------------------------------------------------------------
1921
#if GFX_DISPLAY_DYNAMIC
1923
gu1_get_max_supported_pixel_clock(void)
1926
gfx_get_max_supported_pixel_clock(void)
1929
/* ALL CHIPS CAN HANDLE 1280X1024@85HZ - 157.5 MHz */
1933
/*----------------------------------------------------------------------------
1934
* gfx_get_display_mode
1936
* This routine gets the specified display mode.
1938
* Returns: >0 if successful and mode returned, <0 if mode could not be found.
1939
*----------------------------------------------------------------------------
1941
#if GFX_DISPLAY_DYNAMIC
1943
gu1_get_display_mode(int *xres, int *yres, int *bpp, int *hz)
1946
gfx_get_display_mode(int *xres, int *yres, int *bpp, int *hz)
1949
unsigned int mode = 0;
1950
unsigned long pll_freq = 0, bpp_flag = 0;
1952
*xres = gfx_get_hactive();
1953
*yres = gfx_get_vactive();
1954
*bpp = gfx_get_display_bpp();
1955
pll_freq = gfx_get_clock_frequency();
1957
/* SUPPORT EMULATED VGA MODES */
1958
if (gfx_pixel_double)
1961
if (gfx_line_double)
1964
/* SET BPP FLAGS TO LIMIT MODE SELECTION */
1965
bpp_flag = GFX_MODE_8BPP;
1967
bpp_flag = GFX_MODE_16BPP;
1969
for (mode = 0; mode < NUM_GX_DISPLAY_MODES; mode++) {
1970
if ((DisplayParams[mode].hactive == (unsigned short) *xres) &&
1971
(DisplayParams[mode].vactive == (unsigned short) *yres) &&
1972
(DisplayParams[mode].frequency == pll_freq) &&
1973
(DisplayParams[mode].flags & bpp_flag)) {
1975
pll_freq = DisplayParams[mode].flags;
1977
if (pll_freq & GFX_MODE_56HZ)
1979
else if (pll_freq & GFX_MODE_60HZ)
1981
else if (pll_freq & GFX_MODE_70HZ)
1983
else if (pll_freq & GFX_MODE_72HZ)
1985
else if (pll_freq & GFX_MODE_75HZ)
1987
else if (pll_freq & GFX_MODE_85HZ)
1996
/*---------------------------------------------------------------------------
1998
*---------------------------------------------------------------------------
2000
#if GFX_DISPLAY_DYNAMIC
2002
gu1_get_hactive(void)
2005
gfx_get_hactive(void)
2008
return ((unsigned short) ((READ_REG32(DC_H_TIMING_1) & 0x07F8) + 8));
2011
/*---------------------------------------------------------------------------
2012
* gfx_get_hsync_start
2013
*---------------------------------------------------------------------------
2015
#if GFX_DISPLAY_DYNAMIC
2017
gu1_get_hsync_start(void)
2020
gfx_get_hsync_start(void)
2023
return ((unsigned short) ((READ_REG32(DC_H_TIMING_3) & 0x07F8) + 8));
2026
/*---------------------------------------------------------------------------
2028
*---------------------------------------------------------------------------
2030
#if GFX_DISPLAY_DYNAMIC
2032
gu1_get_hsync_end(void)
2035
gfx_get_hsync_end(void)
2038
return ((unsigned short) (((READ_REG32(DC_H_TIMING_3) >> 16) & 0x07F8) +
2042
/*---------------------------------------------------------------------------
2044
*---------------------------------------------------------------------------
2046
#if GFX_DISPLAY_DYNAMIC
2048
gu1_get_htotal(void)
2051
gfx_get_htotal(void)
2054
return ((unsigned short) (((READ_REG32(DC_H_TIMING_1) >> 16) & 0x07F8) +
2058
/*---------------------------------------------------------------------------
2060
*---------------------------------------------------------------------------
2062
#if GFX_DISPLAY_DYNAMIC
2064
gu1_get_vactive(void)
2067
gfx_get_vactive(void)
2070
return ((unsigned short) ((READ_REG32(DC_V_TIMING_1) & 0x07FF) + 1));
2073
/*---------------------------------------------------------------------------
2075
*---------------------------------------------------------------------------
2077
#if GFX_DISPLAY_DYNAMIC
2079
gu1_get_vsync_end(void)
2082
gfx_get_vsync_end(void)
2085
return ((unsigned short) (((READ_REG32(DC_V_TIMING_3) >> 16) & 0x07FF) +
2089
/*---------------------------------------------------------------------------
2091
*---------------------------------------------------------------------------
2093
#if GFX_DISPLAY_DYNAMIC
2095
gu1_get_vtotal(void)
2098
gfx_get_vtotal(void)
2101
return ((unsigned short) (((READ_REG32(DC_V_TIMING_1) >> 16) & 0x07FF) +
2105
/*-----------------------------------------------------------------------------
2106
* gfx_get_display_bpp
2108
* This routine returns the current color depth of the active display.
2109
*-----------------------------------------------------------------------------
2111
#if GFX_DISPLAY_DYNAMIC
2113
gu1_get_display_bpp(void)
2116
gfx_get_display_bpp(void)
2119
switch (READ_REG32(DC_OUTPUT_CFG) & 3) {
2128
/*---------------------------------------------------------------------------
2130
*---------------------------------------------------------------------------
2132
#if GFX_DISPLAY_DYNAMIC
2140
unsigned short current_scan_line;
2142
/* Read similar value twice to ensure that the value is not transitioning */
2144
current_scan_line = (unsigned short) READ_REG32(DC_V_LINE_CNT) & 0x07FF;
2145
} while (current_scan_line !=
2146
(unsigned short) (READ_REG32(DC_V_LINE_CNT) & 0x07FF));
2148
return (current_scan_line);
2151
/*-----------------------------------------------------------------------------
2152
* gfx_get_display_offset
2153
*-----------------------------------------------------------------------------
2155
#if GFX_DISPLAY_DYNAMIC
2157
gu1_get_display_offset(void)
2160
gfx_get_display_offset(void)
2163
return (READ_REG32(DC_FB_ST_OFFSET) & 0x003FFFFF);
2166
/*-----------------------------------------------------------------------------
2167
* gfx_get_cursor_offset
2168
*-----------------------------------------------------------------------------
2170
#if GFX_DISPLAY_DYNAMIC
2172
gu1_get_cursor_offset(void)
2175
gfx_get_cursor_offset(void)
2178
return (READ_REG32(DC_CURS_ST_OFFSET) & 0x003FFFFF);
2181
#if GFX_READ_ROUTINES
2183
/*************************************************************/
2184
/* READ ROUTINES | INCLUDED FOR DIAGNOSTIC PURPOSES ONLY */
2185
/*************************************************************/
2187
/*---------------------------------------------------------------------------
2188
* gfx_get_hblank_start
2189
*---------------------------------------------------------------------------
2191
#if GFX_DISPLAY_DYNAMIC
2193
gu1_get_hblank_start(void)
2196
gfx_get_hblank_start(void)
2199
return ((unsigned short) ((READ_REG32(DC_H_TIMING_2) & 0x07F8) + 8));
2202
/*---------------------------------------------------------------------------
2203
* gfx_get_hblank_end
2204
*---------------------------------------------------------------------------
2206
#if GFX_DISPLAY_DYNAMIC
2208
gu1_get_hblank_end(void)
2211
gfx_get_hblank_end(void)
2214
return ((unsigned short) (((READ_REG32(DC_H_TIMING_2) >> 16) & 0x07F8) +
2218
/*---------------------------------------------------------------------------
2219
* gfx_get_vblank_start
2220
*---------------------------------------------------------------------------
2222
#if GFX_DISPLAY_DYNAMIC
2224
gu1_get_vblank_start(void)
2227
gfx_get_vblank_start(void)
2230
return ((unsigned short) ((READ_REG32(DC_V_TIMING_2) & 0x07FF) + 1));
2233
/*---------------------------------------------------------------------------
2234
* gfx_get_vsync_start
2235
*---------------------------------------------------------------------------
2237
#if GFX_DISPLAY_DYNAMIC
2239
gu1_get_vsync_start(void)
2242
gfx_get_vsync_start(void)
2245
return ((unsigned short) ((READ_REG32(DC_V_TIMING_3) & 0x07FF) + 1));
2248
/*---------------------------------------------------------------------------
2249
* gfx_get_vblank_end
2250
*---------------------------------------------------------------------------
2252
#if GFX_DISPLAY_DYNAMIC
2254
gu1_get_vblank_end(void)
2257
gfx_get_vblank_end(void)
2260
return ((unsigned short) (((READ_REG32(DC_V_TIMING_2) >> 16) & 0x07FF) +
2264
/*-----------------------------------------------------------------------------
2265
* gfx_get_display_palette_entry
2266
*-----------------------------------------------------------------------------
2268
#if GFX_DISPLAY_DYNAMIC
2270
gu1_get_display_palette_entry(unsigned long index, unsigned long *palette)
2273
gfx_get_display_palette_entry(unsigned long index, unsigned long *palette)
2279
return GFX_STATUS_BAD_PARAMETER;
2281
WRITE_REG32(DC_PAL_ADDRESS, index);
2282
data = READ_REG32(DC_PAL_DATA);
2283
data = ((data << 2) & 0x000000FC) |
2284
((data << 4) & 0x0000FC00) | ((data << 6) & 0x00FC0000);
2290
/*-----------------------------------------------------------------------------
2291
* gfx_get_display_palette
2292
*-----------------------------------------------------------------------------
2294
#if GFX_DISPLAY_DYNAMIC
2296
gu1_get_display_palette(unsigned long *palette)
2299
gfx_get_display_palette(unsigned long *palette)
2302
unsigned long i, data;
2304
WRITE_REG32(DC_PAL_ADDRESS, 0);
2305
for (i = 0; i < 256; i++) {
2306
data = READ_REG32(DC_PAL_DATA);
2307
data = ((data << 2) & 0x000000FC) |
2308
((data << 4) & 0x0000FC00) | ((data << 6) & 0x00FC0000);
2313
/*-----------------------------------------------------------------------------
2314
* gfx_get_cursor_enable
2315
*-----------------------------------------------------------------------------
2317
#if GFX_DISPLAY_DYNAMIC
2319
gu1_get_cursor_enable(void)
2322
gfx_get_cursor_enable(void)
2325
return (READ_REG32(DC_GENERAL_CFG) & DC_GCFG_CURE);
2328
/*-----------------------------------------------------------------------------
2329
* gfx_get_cursor_position
2330
*-----------------------------------------------------------------------------
2332
#if GFX_DISPLAY_DYNAMIC
2334
gu1_get_cursor_position(void)
2337
gfx_get_cursor_position(void)
2340
return ((READ_REG32(DC_CURSOR_X) & 0x07FF) |
2341
((READ_REG32(DC_CURSOR_Y) << 16) & 0x03FF0000));
2344
/*-----------------------------------------------------------------------------
2345
* gfx_get_cursor_clip
2346
*-----------------------------------------------------------------------------
2348
#if GFX_DISPLAY_DYNAMIC
2350
gu1_get_cursor_clip(void)
2353
gfx_get_cursor_clip(void)
2356
return (((READ_REG32(DC_CURSOR_X) >> 11) & 0x01F) |
2357
((READ_REG32(DC_CURSOR_Y) << 5) & 0x1F0000));
2360
/*-----------------------------------------------------------------------------
2361
* gfx_get_cursor_color
2362
*-----------------------------------------------------------------------------
2364
#if GFX_DISPLAY_DYNAMIC
2366
gu1_get_cursor_color(int color)
2369
gfx_get_cursor_color(int color)
2375
WRITE_REG32(DC_PAL_ADDRESS, 0x101);
2378
WRITE_REG32(DC_PAL_ADDRESS, 0x100);
2380
data = READ_REG32(DC_PAL_DATA);
2381
data = ((data << 6) & 0x00FC0000) |
2382
((data << 4) & 0x0000FC00) | ((data << 2) & 0x000000FC);
2386
/*-----------------------------------------------------------------------------
2387
* gfx_get_compression_enable
2388
*-----------------------------------------------------------------------------
2390
#if GFX_DISPLAY_DYNAMIC
2392
gu1_get_compression_enable(void)
2395
gfx_get_compression_enable(void)
2400
gcfg = READ_REG32(DC_GENERAL_CFG);
2401
if (gcfg & DC_GCFG_CMPE)
2407
/*-----------------------------------------------------------------------------
2408
* gfx_get_compression_offset
2409
*-----------------------------------------------------------------------------
2411
#if GFX_DISPLAY_DYNAMIC
2413
gu1_get_compression_offset(void)
2416
gfx_get_compression_offset(void)
2419
unsigned long offset;
2421
offset = READ_REG32(DC_CB_ST_OFFSET) & 0x003FFFFF;
2425
/*-----------------------------------------------------------------------------
2426
* gfx_get_compression_pitch
2427
*-----------------------------------------------------------------------------
2429
#if GFX_DISPLAY_DYNAMIC
2431
gu1_get_compression_pitch(void)
2434
gfx_get_compression_pitch(void)
2437
unsigned short pitch;
2439
pitch = (unsigned short) (READ_REG32(DC_LINE_DELTA) >> 12) & 0x03FF;
2440
return (pitch << 2);
2443
/*-----------------------------------------------------------------------------
2444
* gfx_get_compression_size
2445
*-----------------------------------------------------------------------------
2447
#if GFX_DISPLAY_DYNAMIC
2449
gu1_get_compression_size(void)
2452
gfx_get_compression_size(void)
2455
unsigned short size;
2457
size = (unsigned short) ((READ_REG32(DC_BUF_SIZE) >> 9) & 0x7F) - 1;
2458
return ((size << 2) + 16);
2461
/*-----------------------------------------------------------------------------
2463
*-----------------------------------------------------------------------------
2465
#if GFX_DISPLAY_DYNAMIC
2467
gu1_get_valid_bit(int line)
2470
gfx_get_valid_bit(int line)
2475
WRITE_REG32(MC_DR_ADD, line);
2476
valid = (int) READ_REG32(MC_DR_ACC) & 1;
2480
/*---------------------------------------------------------------------------
2481
* gfx_get_display_video_offset (PRIVATE ROUTINE - NOT PART OF API)
2483
* This routine is called by "gfx_get_video_offset". It abstracts the
2484
* version of the display controller from the video overlay routines.
2485
*---------------------------------------------------------------------------
2487
#if GFX_DISPLAY_DYNAMIC
2489
gu1_get_display_video_offset(void)
2492
gfx_get_display_video_offset(void)
2495
return (READ_REG32(DC_VID_ST_OFFSET) & 0x003FFFFF);
2498
/*---------------------------------------------------------------------------
2499
* gfx_get_display_video_size (PRIVATE ROUTINE - NOT PART OF API)
2501
* This routine is called by "gfx_get_video_size". It abstracts the
2502
* version of the display controller from the video overlay routines.
2503
*---------------------------------------------------------------------------
2505
#if GFX_DISPLAY_DYNAMIC
2507
gu1_get_display_video_size(void)
2510
gfx_get_display_video_size(void)
2513
/* RETURN TOTAL SIZE, IN BYTES */
2514
return ((READ_REG32(DC_BUF_SIZE) >> 10) & 0x000FFFC0);
2517
/*-----------------------------------------------------------------------------
2518
* gfx_get_display_priority_high
2519
*-----------------------------------------------------------------------------
2521
#if GFX_DISPLAY_DYNAMIC
2523
gu1_get_display_priority_high(void)
2526
gfx_get_display_priority_high(void)
2529
if (READ_REG32(MC_MEM_CNTRL1) & MC_XBUSARB)
2535
#endif /* GFX_READ_ROUTINES */