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.
27
* This file contains routines for the second generation display controller.
30
void gu2_enable_compression(void); /* private routine definition */
31
void gu2_disable_compression(void); /* private routine definition */
32
int gfx_set_display_control(int sync_polarities); /* private routine
34
void gfx_reset_video(void);
35
int gu2_set_specified_mode(DISPLAYMODE * pMode, int bpp);
37
/*---------------------------------------------------------------------------
38
* WARNING!!!! INACCURATE DELAY MECHANISM
40
* In an effort to keep the code self contained and operating system
41
* independent, the delay loop just performs reads of a display controller
42
* register. This time will vary for faster processors. The delay can always
43
* be longer than intended, only effecting the time of the mode switch
44
* (obviously want it to still be under a second). Problems with the hardware
45
* only arise if the delay is not long enough.
46
*----------------------------------------------------------------------------
48
#define RC_READS_PER_MILLISECOND 15000L
50
#if GFX_DISPLAY_DYNAMIC
52
gu2_delay_milliseconds(unsigned long milliseconds)
55
gfx_delay_milliseconds(unsigned long milliseconds)
58
/* ASSUME 300 MHZ 20 CLOCKS PER READ */
61
loop = milliseconds * RC_READS_PER_MILLISECOND;
63
READ_REG32(MDC_UNLOCK);
67
#if GFX_DISPLAY_DYNAMIC
69
gu2_delay_microseconds(unsigned long microseconds)
72
gfx_delay_microseconds(unsigned long microseconds)
75
/* ASSUME 400 MHz, 2 CLOCKS PER INCREMENT */
76
unsigned long loop_count = microseconds * 15;
78
while (loop_count-- > 0) {
79
READ_REG32(MDC_UNLOCK);
83
/*----------------------------------------------------------------------------
86
* This routine programs the bpp in the display controller.
87
*----------------------------------------------------------------------------
89
#if GFX_DISPLAY_DYNAMIC
91
gu2_set_display_bpp(unsigned short bpp)
94
gfx_set_display_bpp(unsigned short bpp)
97
unsigned long dcfg, lock;
100
READ_REG32(MDC_DISPLAY_CFG) & ~(MDC_DCFG_DISP_MODE_MASK |
101
MDC_DCFG_16BPP_MODE_MASK);
102
lock = READ_REG32(MDC_UNLOCK);
106
dcfg |= (MDC_DCFG_DISP_MODE_16BPP | MDC_DCFG_12BPP);
109
dcfg |= (MDC_DCFG_DISP_MODE_16BPP | MDC_DCFG_15BPP);
112
dcfg |= (MDC_DCFG_DISP_MODE_16BPP | MDC_DCFG_16BPP);
115
dcfg |= (MDC_DCFG_DISP_MODE_24BPP);
118
dcfg |= (MDC_DCFG_DISP_MODE_8BPP);
121
return GFX_STATUS_BAD_PARAMETER;
124
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
125
WRITE_REG32(MDC_DISPLAY_CFG, dcfg);
126
WRITE_REG32(MDC_UNLOCK, lock);
128
/* SET BPP IN GRAPHICS PIPELINE */
134
/*----------------------------------------------------------------------------
135
* gu2_set_specified_mode (private routine)
136
* This routine uses the parameters in the specified display mode structure
137
* to program the display controller hardware.
138
*----------------------------------------------------------------------------
141
gu2_set_specified_mode(DISPLAYMODE * pMode, int bpp)
143
unsigned long unlock, value;
144
unsigned long gcfg, dcfg;
145
unsigned long size, pitch;
146
unsigned long vid_buf_size;
147
unsigned long bpp_mask, temp, dv_size;
149
/* CHECK WHETHER TIMING CHANGE IS ALLOWED */
150
/* Flag used for locking also overrides timing change restriction */
151
if (gfx_timing_lock && !(pMode->flags & GFX_MODE_LOCK_TIMING))
152
return GFX_STATUS_ERROR;
154
/* CLEAR PANNING OFFSETS */
160
/* SET GLOBAL FLAG */
162
if (pMode->flags & GFX_MODE_LOCK_TIMING)
165
/* CHECK FOR VALID BPP */
166
/* As this function can be called directly from */
167
/* gfx_set_display_timings, we must correct any */
168
/* invalid bpp settings. */
171
bpp_mask = 0x00000900;
174
bpp_mask = 0x00000500;
177
bpp_mask = 0x00000100;
180
bpp_mask = 0x00000200;
183
bpp_mask = 0x00000000;
190
/* DISABLE COMPRESSION */
191
gu2_disable_compression();
193
/* ALSO DISABLE VIDEO */
194
/* Use private "reset video" routine to do all that is needed. */
195
/* SC1200, for example, also disables the alpha blending regions. */
198
/* UNLOCK THE DISPLAY CONTROLLER REGISTERS */
199
unlock = READ_REG32(MDC_UNLOCK);
200
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
202
/* READ THE CURRENT REGISTER VALUES */
203
gcfg = READ_REG32(MDC_GENERAL_CFG);
204
dcfg = READ_REG32(MDC_DISPLAY_CFG);
206
/* BLANK THE DISPLAY IN THE DISPLAY FILTER */
207
gfx_set_crt_enable(0);
209
/* DISABLE THE TIMING GENERATOR */
210
dcfg &= ~(unsigned long) MDC_DCFG_TGEN;
211
WRITE_REG32(MDC_DISPLAY_CFG, dcfg);
213
/* DELAY: WAIT FOR PENDING MEMORY REQUESTS */
214
/* This delay is used to make sure that all pending requests to the */
215
/* memory controller have completed before disabling the FIFO load. */
216
gfx_delay_milliseconds(5);
218
/* DISABLE DISPLAY FIFO LOAD */
219
gcfg &= ~(unsigned long) MDC_GCFG_DFLE;
220
WRITE_REG32(MDC_GENERAL_CFG, gcfg);
222
/* PRESERVE VIDEO INFORMATION */
223
gcfg &= (unsigned long) (MDC_GCFG_YUVM | MDC_GCFG_VDSE);
226
/* SET THE DOT CLOCK FREQUENCY */
227
/* Mask off the divide by two bit (bit 31) */
228
if (!(pMode->flags & GFX_MODE_EXCLUDE_PLL))
229
gfx_set_clock_frequency(pMode->frequency & 0x7FFFFFFF);
231
/* DELAY: WAIT FOR THE PLL TO SETTLE */
232
/* This allows the dot clock frequency that was just set to settle. */
233
gfx_delay_milliseconds(10);
235
/* SET THE GX DISPLAY CONTROLLER PARAMETERS */
236
WRITE_REG32(MDC_FB_ST_OFFSET, 0);
237
WRITE_REG32(MDC_CB_ST_OFFSET, 0);
238
WRITE_REG32(MDC_CURS_ST_OFFSET, 0);
239
WRITE_REG32(MDC_ICON_ST_OFFSET, 0);
241
/* SET LINE SIZE AND PITCH */
242
/* 1. Flat Panels must use the mode width and not */
243
/* the timing width to set the pitch. */
244
/* 2. Mode sets will use a pitch that is aligned */
245
/* on a 1K boundary to preserve legacy. The */
246
/* pitch can be overridden by a subsequent call */
247
/* to gfx_set_display_pitch. */
251
size = pMode->hactive;
260
dv_size = MDC_DV_LINE_SIZE_1024;
264
dv_size = MDC_DV_LINE_SIZE_2048;
269
dv_size = MDC_DV_LINE_SIZE_4096;
274
dv_size = MDC_DV_LINE_SIZE_8192;
277
WRITE_REG32(MDC_GFX_PITCH, pitch >> 3);
279
/* WRITE DIRTY/VALID CONTROL WITH LINE LENGTH */
280
temp = READ_REG32(MDC_DV_CTL);
281
WRITE_REG32(MDC_DV_CTL, (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size);
284
size = pMode->hactive;
291
/* SAVE PREVIOUSLY STORED VIDEO LINE SIZE */
292
vid_buf_size = READ_REG32(MDC_LINE_SIZE) & 0xFF000000;
294
/* ADD 2 TO SIZE FOR POSSIBLE START ADDRESS ALIGNMENTS */
295
WRITE_REG32(MDC_LINE_SIZE, ((size >> 3) + 2) | vid_buf_size);
297
/* ALWAYS ENABLE VIDEO AND GRAPHICS DATA */
298
/* These bits are relics from a previous design and */
299
/* should always be enabled. */
300
dcfg |= (unsigned long) (MDC_DCFG_VDEN | MDC_DCFG_GDEN);
302
/* SET PIXEL FORMAT */
305
/* ENABLE TIMING GENERATOR, TIM. REG. UPDATES, PALETTE BYPASS */
306
/* AND VERT. INT. SELECT */
308
(unsigned long) (MDC_DCFG_TGEN | MDC_DCFG_TRUP | MDC_DCFG_PALB |
311
/* DISABLE ADDRESS MASKS */
312
dcfg |= MDC_DCFG_A20M;
313
dcfg |= MDC_DCFG_A18M;
315
/* SET FIFO PRIORITIES AND DISPLAY FIFO LOAD ENABLE */
316
/* Set the priorities higher for high resolution modes. */
317
if (pMode->hactive > 1024 || bpp == 32)
322
/* ENABLE FLAT PANEL CENTERING */
323
/* For panel modes having a resolution smaller than the */
324
/* panel resolution, turn on data centering. */
325
if (PanelEnable && ModeWidth < PanelWidth)
326
dcfg |= MDC_DCFG_DCEN;
328
/* COMBINE AND SET TIMING VALUES */
329
value = (unsigned long) (pMode->hactive - 1) |
330
(((unsigned long) (pMode->htotal - 1)) << 16);
331
WRITE_REG32(MDC_H_ACTIVE_TIMING, value);
332
value = (unsigned long) (pMode->hblankstart - 1) |
333
(((unsigned long) (pMode->hblankend - 1)) << 16);
334
WRITE_REG32(MDC_H_BLANK_TIMING, value);
335
value = (unsigned long) (pMode->hsyncstart - 1) |
336
(((unsigned long) (pMode->hsyncend - 1)) << 16);
337
WRITE_REG32(MDC_H_SYNC_TIMING, value);
338
value = (unsigned long) (pMode->vactive - 1) |
339
(((unsigned long) (pMode->vtotal - 1)) << 16);
340
WRITE_REG32(MDC_V_ACTIVE_TIMING, value);
341
value = (unsigned long) (pMode->vblankstart - 1) |
342
(((unsigned long) (pMode->vblankend - 1)) << 16);
343
WRITE_REG32(MDC_V_BLANK_TIMING, value);
344
value = (unsigned long) (pMode->vsyncstart - 1) |
345
(((unsigned long) (pMode->vsyncend - 1)) << 16);
346
WRITE_REG32(MDC_V_SYNC_TIMING, value);
348
WRITE_REG32(MDC_DISPLAY_CFG, dcfg);
349
WRITE_REG32(MDC_GENERAL_CFG, gcfg);
351
/* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */
352
gfx_set_display_control(((pMode->flags & GFX_MODE_NEG_HSYNC) ? 1 : 0) |
353
((pMode->flags & GFX_MODE_NEG_VSYNC) ? 2 : 0));
355
/* RESTORE VALUE OF MDC_UNLOCK */
356
WRITE_REG32(MDC_UNLOCK, unlock);
358
/* RESET THE PITCH VALUES IN THE GP */
359
gfx_reset_pitch((unsigned short) pitch);
361
gfx_set_bpp((unsigned short) bpp);
363
return GFX_STATUS_OK;
366
/*----------------------------------------------------------------------------
367
* GFX_IS_DISPLAY_MODE_SUPPORTED
369
* This routine sets the specified display mode.
371
* Returns 1 if successful, 0 if mode could not be set.
372
*----------------------------------------------------------------------------
374
#if GFX_DISPLAY_DYNAMIC
376
gu2_is_display_mode_supported(int xres, int yres, int bpp, int hz)
379
gfx_is_display_mode_supported(int xres, int yres, int bpp, int hz)
383
unsigned long hz_flag = 0, bpp_flag = 0;
385
/* SET FLAGS TO MATCH REFRESH RATE */
386
gfx_mode_hz_conversion
387
/* SET BPP FLAGS TO LIMIT MODE SELECTION */
388
gfx_mode_bpp_conversion
389
/* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */
390
for (mode = 0; mode < NUM_RC_DISPLAY_MODES; mode++) {
391
if ((DisplayParams[mode].hactive == (unsigned short) xres) &&
392
(DisplayParams[mode].vactive == (unsigned short) yres) &&
393
(DisplayParams[mode].flags & hz_flag) &&
394
(DisplayParams[mode].flags & bpp_flag)) {
396
/* REDCLOUD DOES NOT SUPPORT EMULATED VGA MODES */
397
if ((DisplayParams[mode].flags & GFX_MODE_PIXEL_DOUBLE) ||
398
(DisplayParams[mode].flags & GFX_MODE_LINE_DOUBLE))
401
/* SET THE DISPLAY CONTROLLER FOR THE SELECTED MODE */
408
/*----------------------------------------------------------------------------
409
* gfx_set_display_mode
411
* This routine sets the specified display mode.
413
* Returns 1 if successful, 0 if mode could not be set.
414
*----------------------------------------------------------------------------
416
#if GFX_DISPLAY_DYNAMIC
418
gu2_set_display_mode(int xres, int yres, int bpp, int hz)
421
gfx_set_display_mode(int xres, int yres, int bpp, int hz)
426
/* DISABLE FLAT PANEL */
427
/* Flat Panel settings are enabled by the function gfx_set_fixed_timings
428
* and disabled by gfx_set_display_mode.
432
mode = gfx_is_display_mode_supported(xres, yres, bpp, hz);
434
if (gu2_set_specified_mode(&DisplayParams[mode], bpp) == GFX_STATUS_OK)
440
/*----------------------------------------------------------------------------
441
* GFX_SET_DISPLAY_TIMINGS
443
* This routine sets the display controller mode using the specified timing
444
* values (as opposed to using the tables internal to Durango).
446
* Returns GFX_STATUS_OK ON SUCCESS, GFX_STATUS_ERROR otherwise.
447
*----------------------------------------------------------------------------
449
#if GFX_DISPLAY_DYNAMIC
451
gu2_set_display_timings(unsigned short bpp, unsigned short flags,
452
unsigned short hactive, unsigned short hblankstart,
453
unsigned short hsyncstart, unsigned short hsyncend,
454
unsigned short hblankend, unsigned short htotal,
455
unsigned short vactive, unsigned short vblankstart,
456
unsigned short vsyncstart, unsigned short vsyncend,
457
unsigned short vblankend, unsigned short vtotal,
458
unsigned long frequency)
461
gfx_set_display_timings(unsigned short bpp, unsigned short flags,
462
unsigned short hactive, unsigned short hblankstart,
463
unsigned short hsyncstart, unsigned short hsyncend,
464
unsigned short hblankend, unsigned short htotal,
465
unsigned short vactive, unsigned short vblankstart,
466
unsigned short vsyncstart, unsigned short vsyncend,
467
unsigned short vblankend, unsigned short vtotal,
468
unsigned long frequency)
471
/* SET MODE STRUCTURE WITH SPECIFIED VALUES */
473
gfx_display_mode.flags = 0;
475
gfx_display_mode.flags |= GFX_MODE_NEG_HSYNC;
477
gfx_display_mode.flags |= GFX_MODE_NEG_VSYNC;
479
gfx_display_mode.flags |= GFX_MODE_EXCLUDE_PLL;
481
gfx_display_mode.flags |= GFX_MODE_LOCK_TIMING;
482
gfx_display_mode.hactive = hactive;
483
gfx_display_mode.hblankstart = hblankstart;
484
gfx_display_mode.hsyncstart = hsyncstart;
485
gfx_display_mode.hsyncend = hsyncend;
486
gfx_display_mode.hblankend = hblankend;
487
gfx_display_mode.htotal = htotal;
488
gfx_display_mode.vactive = vactive;
489
gfx_display_mode.vblankstart = vblankstart;
490
gfx_display_mode.vsyncstart = vsyncstart;
491
gfx_display_mode.vsyncend = vsyncend;
492
gfx_display_mode.vblankend = vblankend;
493
gfx_display_mode.vtotal = vtotal;
494
gfx_display_mode.frequency = frequency;
496
/* CALL ROUTINE TO SET MODE */
497
return (gu2_set_specified_mode(&gfx_display_mode, bpp));
500
/*----------------------------------------------------------------------------
503
* This routine sets the display controller vertical total to
504
* "vtotal". As a side effect it also sets vertical blank end.
505
* It should be used when only this value needs to be changed,
506
* due to speed considerations.
508
* Note: it is the caller's responsibility to make sure that
509
* a legal vtotal is used, i.e. that "vtotal" is greater than or
510
* equal to vsync end.
513
*----------------------------------------------------------------------------
515
#if GFX_DISPLAY_DYNAMIC
517
gu2_set_vtotal(unsigned short vtotal)
520
gfx_set_vtotal(unsigned short vtotal)
523
unsigned long unlock, dcfg, vactive, vblank;
525
/* UNLOCK THE DISPLAY CONTROLLER REGISTERS */
526
unlock = READ_REG32(MDC_UNLOCK);
527
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
529
/* READ THE CURRENT RC VALUES */
530
dcfg = READ_REG32(MDC_DISPLAY_CFG);
531
vactive = READ_REG32(MDC_V_ACTIVE_TIMING);
532
vblank = READ_REG32(MDC_V_BLANK_TIMING);
534
/* DISABLE TIMING REGISTER UPDATES */
535
WRITE_REG32(MDC_DISPLAY_CFG, dcfg & ~(unsigned long) MDC_DCFG_TRUP);
537
/* WRITE NEW TIMING VALUES */
538
WRITE_REG32(MDC_V_ACTIVE_TIMING,
539
(vactive & MDC_VAT_VA_MASK) | (unsigned long) (vtotal -
541
WRITE_REG32(MDC_V_BLANK_TIMING,
542
(vblank & MDC_VBT_VBS_MASK) | (unsigned long) (vtotal -
545
/* RESTORE OLD RC VALUES */
546
WRITE_REG32(MDC_DISPLAY_CFG, dcfg);
547
WRITE_REG32(MDC_UNLOCK, unlock);
552
/*---------------------------------------------------------------------------
553
* gfx_set_display_pitch
555
* This routine sets the pitch of the frame buffer to the specified value.
556
*---------------------------------------------------------------------------
558
#if GFX_DISPLAY_DYNAMIC
560
gu2_set_display_pitch(unsigned short pitch)
563
gfx_set_display_pitch(unsigned short pitch)
566
unsigned long value = 0;
567
unsigned long lock = READ_REG32(MDC_UNLOCK);
569
value = READ_REG32(MDC_GFX_PITCH) & 0xFFFF0000;
570
value |= (pitch >> 3);
571
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
572
WRITE_REG32(MDC_GFX_PITCH, value);
574
/* SET RENDERING PITCHES TO MATCH */
575
gfx_reset_pitch(pitch);
577
/* SET THE FRAME DIRTY MODE */
578
/* Non-standard pitches, i.e. pitches that */
579
/* are not 1K, 2K or 4K must mark the entire */
580
/* frame as dirty when writing to the frame */
582
value = READ_REG32(MDC_GENERAL_CFG);
584
if (pitch == 1024 || pitch == 2048 || pitch == 4096 || pitch == 8192)
585
value &= ~(unsigned long) (MDC_GCFG_FDTY);
587
value |= (unsigned long) (MDC_GCFG_FDTY);
589
WRITE_REG32(MDC_GENERAL_CFG, value);
590
WRITE_REG32(MDC_UNLOCK, lock);
593
/*---------------------------------------------------------------------------
594
* gfx_set_display_offset
596
* This routine sets the start address of the frame buffer. It is
597
* typically used to pan across a virtual desktop (frame buffer larger than
598
* the displayed screen) or to flip the display between multiple buffers.
599
*---------------------------------------------------------------------------
601
#if GFX_DISPLAY_DYNAMIC
603
gu2_set_display_offset(unsigned long offset)
606
gfx_set_display_offset(unsigned long offset)
609
/* UPDATE FRAME BUFFER OFFSET */
612
lock = READ_REG32(MDC_UNLOCK);
613
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
615
/* START ADDRESS EFFECTS DISPLAY COMPRESSION */
616
/* Disable compression for non-zero start addresss values. */
617
/* Enable compression if offset is zero and comression is intended to */
618
/* be enabled from a previous call to "gfx_set_compression_enable". */
619
/* Compression should be disabled BEFORE the offset is changed */
620
/* and enabled AFTER the offset is changed. */
622
WRITE_REG32(MDC_FB_ST_OFFSET, offset);
623
if (gfx_compression_enabled) {
624
/* WAIT FOR THE OFFSET TO BE LATCHED */
625
gfx_wait_vertical_blank();
626
gu2_enable_compression();
630
/* ONLY DISABLE COMPRESSION ONCE */
631
if (gfx_compression_active)
632
gu2_disable_compression();
634
WRITE_REG32(MDC_FB_ST_OFFSET, offset);
637
WRITE_REG32(MDC_UNLOCK, lock);
640
/*---------------------------------------------------------------------------
641
* gfx_set_display_palette_entry
643
* This routine sets an palette entry in the display controller.
644
* A 32-bit X:R:G:B value.
645
*---------------------------------------------------------------------------
647
#if GFX_DISPLAY_DYNAMIC
649
gu2_set_display_palette_entry(unsigned long index, unsigned long palette)
652
gfx_set_display_palette_entry(unsigned long index, unsigned long palette)
655
unsigned long dcfg, unlock;
658
return GFX_STATUS_BAD_PARAMETER;
660
unlock = READ_REG32(MDC_UNLOCK);
661
dcfg = READ_REG32(MDC_DISPLAY_CFG);
663
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
664
WRITE_REG32(MDC_DISPLAY_CFG, dcfg & ~MDC_DCFG_PALB);
665
WRITE_REG32(MDC_UNLOCK, unlock);
667
WRITE_REG32(MDC_PAL_ADDRESS, index);
668
WRITE_REG32(MDC_PAL_DATA, palette);
670
return GFX_STATUS_OK;
673
/*---------------------------------------------------------------------------
674
* gfx_set_display_palette
676
* This routine sets the entire palette in the display controller.
677
* A pointer is provided to a 256 entry table of 32-bit X:R:G:B values.
678
*---------------------------------------------------------------------------
680
#if GFX_DISPLAY_DYNAMIC
682
gu2_set_display_palette(unsigned long *palette)
685
gfx_set_display_palette(unsigned long *palette)
688
unsigned long unlock, dcfg, i;
690
WRITE_REG32(MDC_PAL_ADDRESS, 0);
693
unlock = READ_REG32(MDC_UNLOCK);
694
dcfg = READ_REG32(MDC_DISPLAY_CFG);
696
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
697
WRITE_REG32(MDC_DISPLAY_CFG, dcfg & ~MDC_DCFG_PALB);
698
WRITE_REG32(MDC_UNLOCK, unlock);
700
for (i = 0; i < 256; i++)
701
WRITE_REG32(MDC_PAL_DATA, palette[i]);
703
return GFX_STATUS_OK;
705
return GFX_STATUS_BAD_PARAMETER;
708
/*---------------------------------------------------------------------------
709
* gfx_set_cursor_enable
711
* This routine enables or disables the hardware cursor.
713
* WARNING: The cursor start offset must be set by setting the cursor
714
* position before calling this routine to assure that memory reads do not
715
* go past the end of graphics memory (this can hang GXm).
716
*---------------------------------------------------------------------------
718
#if GFX_DISPLAY_DYNAMIC
720
gu2_set_cursor_enable(int enable)
723
gfx_set_cursor_enable(int enable)
726
unsigned long unlock, gcfg;
728
/* SET OR CLEAR CURSOR ENABLE BIT */
729
unlock = READ_REG32(MDC_UNLOCK);
730
gcfg = READ_REG32(MDC_GENERAL_CFG);
732
gcfg |= MDC_GCFG_CURE;
734
gcfg &= ~(MDC_GCFG_CURE);
736
/* WRITE NEW REGISTER VALUE */
737
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
738
WRITE_REG32(MDC_GENERAL_CFG, gcfg);
739
WRITE_REG32(MDC_UNLOCK, unlock);
742
/*---------------------------------------------------------------------------
743
* gfx_set_cursor_colors
745
* This routine sets the colors of the hardware cursor.
746
*---------------------------------------------------------------------------
748
#if GFX_DISPLAY_DYNAMIC
750
gu2_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor)
753
gfx_set_cursor_colors(unsigned long bkcolor, unsigned long fgcolor)
756
/* SET CURSOR COLORS */
757
WRITE_REG32(MDC_PAL_ADDRESS, 0x100);
758
WRITE_REG32(MDC_PAL_DATA, bkcolor);
759
WRITE_REG32(MDC_PAL_DATA, fgcolor);
762
/*---------------------------------------------------------------------------
763
* gfx_set_cursor_position
765
* This routine sets the position of the hardware cusror. The starting
766
* offset of the cursor buffer must be specified so that the routine can
767
* properly clip scanlines if the cursor is off the top of the screen.
768
*---------------------------------------------------------------------------
770
#if GFX_DISPLAY_DYNAMIC
772
gu2_set_cursor_position(unsigned long memoffset,
773
unsigned short xpos, unsigned short ypos,
774
unsigned short xhotspot, unsigned short yhotspot)
777
gfx_set_cursor_position(unsigned long memoffset,
778
unsigned short xpos, unsigned short ypos,
779
unsigned short xhotspot, unsigned short yhotspot)
782
unsigned long unlock;
784
short x = (short) xpos - (short) xhotspot;
785
short y = (short) ypos - (short) yhotspot;
795
if ((ModeWidth > PanelWidth) || (ModeHeight > PanelHeight)) {
796
gfx_enable_panning(xpos, ypos);
797
x = x - (unsigned short) panelLeft;
798
y = y - (unsigned short) panelTop;
803
/* Cursor movement and panning work as follows: The cursor position */
804
/* refers to where the hotspot of the cursor is located. However, for */
805
/* non-zero hotspots, the cursor buffer actually begins before the */
806
/* specified position. */
816
memoffset += (unsigned long) yoffset << 4;
818
/* SET CURSOR POSITION */
819
unlock = READ_REG32(MDC_UNLOCK);
820
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
821
WRITE_REG32(MDC_CURS_ST_OFFSET, memoffset);
822
WRITE_REG32(MDC_CURSOR_X, (unsigned long) x |
823
(((unsigned long) xoffset) << 11));
824
WRITE_REG32(MDC_CURSOR_Y, (unsigned long) y |
825
(((unsigned long) yoffset) << 11));
826
WRITE_REG32(MDC_UNLOCK, unlock);
829
/*---------------------------------------------------------------------------
830
* gfx_set_cursor_shape32
832
* This routine loads 32x32 cursor data into the cursor buffer in graphics
834
* As the Redcloud cursor is actually 64x64, we must pad the outside of the
835
* cursor data with transparent pixels.
836
*---------------------------------------------------------------------------
838
#if GFX_DISPLAY_DYNAMIC
840
gu2_set_cursor_shape32(unsigned long memoffset,
841
unsigned long *andmask, unsigned long *xormask)
844
gfx_set_cursor_shape32(unsigned long memoffset,
845
unsigned long *andmask, unsigned long *xormask)
850
for (i = 0; i < 32; i++) {
851
/* EVEN QWORDS CONTAIN THE AND MASK */
852
WRITE_FB32(memoffset, 0xFFFFFFFF);
853
WRITE_FB32(memoffset + 4, andmask[i]);
855
/* ODD QWORDS CONTAIN THE XOR MASK */
856
WRITE_FB32(memoffset + 8, 0x00000000);
857
WRITE_FB32(memoffset + 12, xormask[i]);
862
/* FILL THE LOWER HALF OF THE BUFFER WITH TRANSPARENT PIXELS */
863
for (i = 0; i < 32; i++) {
864
WRITE_FB32(memoffset, 0xFFFFFFFF);
865
WRITE_FB32(memoffset + 4, 0xFFFFFFFF);
866
WRITE_FB32(memoffset + 8, 0x00000000);
867
WRITE_FB32(memoffset + 12, 0x00000000);
873
/*---------------------------------------------------------------------------
874
* gfx_set_cursor_shape64
876
* This routine loads 64x64 cursor data into the cursor buffer in graphics
878
*---------------------------------------------------------------------------
880
#if GFX_DISPLAY_DYNAMIC
882
gu2_set_cursor_shape64(unsigned long memoffset,
883
unsigned long *andmask, unsigned long *xormask)
886
gfx_set_cursor_shape64(unsigned long memoffset,
887
unsigned long *andmask, unsigned long *xormask)
892
for (i = 0; i < 128; i += 2) {
893
/* EVEN QWORDS CONTAIN THE AND MASK */
894
/* We invert the dwords to prevent the calling */
895
/* application from having to think in terms of Qwords. */
896
/* The hardware data order is actually 63:0, or 31:0 of */
897
/* the second dword followed by 31:0 of the first dword. */
898
WRITE_FB32(memoffset, andmask[i + 1]);
899
WRITE_FB32(memoffset + 4, andmask[i]);
901
/* ODD QWORDS CONTAIN THE XOR MASK */
902
WRITE_FB32(memoffset + 8, xormask[i + 1]);
903
WRITE_FB32(memoffset + 12, xormask[i]);
909
/*---------------------------------------------------------------------------
910
* gfx_set_icon_enable
912
* This routine enables or disables the hardware icon. The icon position
913
* and colors should be programmed prior to calling this routine for the
915
*---------------------------------------------------------------------------
917
#if GFX_DISPLAY_DYNAMIC
919
gu2_set_icon_enable(int enable)
922
gfx_set_icon_enable(int enable)
925
unsigned long unlock, gcfg;
927
/* SET OR CLEAR ICON ENABLE BIT */
928
unlock = READ_REG32(MDC_UNLOCK);
929
gcfg = READ_REG32(MDC_GENERAL_CFG);
931
gcfg |= MDC_GCFG_ICNE;
933
gcfg &= ~(MDC_GCFG_ICNE);
935
/* WRITE NEW REGISTER VALUE */
936
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
937
WRITE_REG32(MDC_GENERAL_CFG, gcfg);
938
WRITE_REG32(MDC_UNLOCK, unlock);
941
/*---------------------------------------------------------------------------
942
* gfx_set_icon_colors
944
* This routine sets the three icon colors.
945
*---------------------------------------------------------------------------
947
#if GFX_DISPLAY_DYNAMIC
949
gu2_set_icon_colors(unsigned long color0, unsigned long color1,
950
unsigned long color2)
953
gfx_set_icon_colors(unsigned long color0, unsigned long color1,
954
unsigned long color2)
957
/* ICON COLORS LOCATED AT PALETTE INDEXES 102-104h */
958
WRITE_REG32(MDC_PAL_ADDRESS, 0x102);
960
WRITE_REG32(MDC_PAL_DATA, color0);
961
WRITE_REG32(MDC_PAL_DATA, color1);
962
WRITE_REG32(MDC_PAL_DATA, color2);
965
/*---------------------------------------------------------------------------
966
* gfx_set_icon_position
968
* This routine sets the starting X coordinate for the hardware icon and the
969
* memory offset for the icon buffer.
970
*---------------------------------------------------------------------------
972
#if GFX_DISPLAY_DYNAMIC
974
gu2_set_icon_position(unsigned long memoffset, unsigned short xpos)
977
gfx_set_icon_position(unsigned long memoffset, unsigned short xpos)
980
unsigned long lock = READ_REG32(MDC_UNLOCK);
982
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
984
/* PROGRAM THE MEMORY OFFSET */
985
WRITE_REG32(MDC_ICON_ST_OFFSET, memoffset & 0x0FFFFFFF);
987
/* PROGRAM THE XCOORDINATE */
988
WRITE_REG32(MDC_ICON_X, (unsigned long) (xpos & 0x07FF));
990
WRITE_REG32(MDC_UNLOCK, lock);
993
/*---------------------------------------------------------------------------
994
* gfx_set_icon_shape64
996
* This routine initializes the icon buffer according to the current mode.
997
*---------------------------------------------------------------------------
999
#if GFX_DISPLAY_DYNAMIC
1001
gu2_set_icon_shape64(unsigned long memoffset, unsigned long *andmask,
1002
unsigned long *xormask, unsigned int lines)
1005
gfx_set_icon_shape64(unsigned long memoffset, unsigned long *andmask,
1006
unsigned long *xormask, unsigned int lines)
1009
unsigned short i, height;
1011
height = lines << 1;
1013
for (i = 0; i < height; i += 2) {
1014
/* EVEN QWORDS CONTAIN THE AND MASK */
1015
/* Swap dwords to hide qword constraint */
1016
WRITE_FB32(memoffset, andmask[i + 1]);
1017
WRITE_FB32(memoffset + 4, andmask[i]);
1019
/* ODD QWORDS CONTAIN THE XOR MASK */
1020
WRITE_FB32(memoffset + 8, xormask[i + 1]);
1021
WRITE_FB32(memoffset + 12, xormask[i]);
1027
/*---------------------------------------------------------------------------
1028
* gu2_enable_compression
1030
* This is a private routine to this module (not exposed in the Durango API).
1031
* It enables display compression.
1032
*---------------------------------------------------------------------------
1035
gu2_enable_compression(void)
1037
unsigned long unlock, gcfg, temp;
1039
/* DO NOT ENABLE IF START ADDRESS IS NOT ZERO */
1040
if (READ_REG32(MDC_FB_ST_OFFSET) & 0x0FFFFFFF)
1043
/* SET GLOBAL INDICATOR */
1044
gfx_compression_active = 1;
1046
/* CLEAR DIRTY/VALID BITS IN MEMORY CONTROLLER */
1047
/* Software is required to do this before enabling compression. */
1048
/* Don't want controller to think that old lines are still valid. */
1049
/* Writing a 1 to bit 0 of the DV Control register will force the */
1050
/* hardware to clear all the valid bits. */
1051
temp = READ_REG32(MDC_DV_CTL);
1052
WRITE_REG32(MDC_DV_CTL, temp | 0x00000001);
1054
/* TURN ON COMPRESSION CONTROL BITS */
1055
unlock = READ_REG32(MDC_UNLOCK);
1056
gcfg = READ_REG32(MDC_GENERAL_CFG);
1057
gcfg |= MDC_GCFG_CMPE | MDC_GCFG_DECE;
1058
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1059
WRITE_REG32(MDC_GENERAL_CFG, gcfg);
1060
WRITE_REG32(MDC_UNLOCK, unlock);
1063
/*---------------------------------------------------------------------------
1064
* gu2_disable_compression
1066
* This is a private routine to this module (not exposed in the Durango API).
1067
* It disables display compression.
1068
*---------------------------------------------------------------------------
1071
gu2_disable_compression(void)
1073
unsigned long unlock, gcfg;
1075
/* SET GLOBAL INDICATOR */
1077
gfx_compression_active = 0;
1079
/* TURN OFF COMPRESSION CONTROL BITS */
1081
unlock = READ_REG32(MDC_UNLOCK);
1082
gcfg = READ_REG32(MDC_GENERAL_CFG);
1083
gcfg &= ~(MDC_GCFG_CMPE | MDC_GCFG_DECE);
1084
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1085
WRITE_REG32(MDC_GENERAL_CFG, gcfg);
1086
WRITE_REG32(MDC_UNLOCK, unlock);
1089
/*---------------------------------------------------------------------------
1090
* gfx_set_compression_enable
1092
* This routine enables or disables display compression.
1093
*---------------------------------------------------------------------------
1095
#if GFX_DISPLAY_DYNAMIC
1097
gu2_set_compression_enable(int enable)
1100
gfx_set_compression_enable(int enable)
1103
/* SET GLOBAL VARIABLE FOR INDENDED STATE */
1104
/* Compression can only be enabled for non-zero start address values. */
1105
/* Keep state to enable compression on start address changes. */
1107
gfx_compression_enabled = enable;
1109
gu2_enable_compression();
1111
gu2_disable_compression();
1115
/*---------------------------------------------------------------------------
1116
* gfx_set_compression_offset
1118
* This routine sets the base offset for the compression buffer.
1119
*---------------------------------------------------------------------------
1121
#if GFX_DISPLAY_DYNAMIC
1123
gu2_set_compression_offset(unsigned long offset)
1126
gfx_set_compression_offset(unsigned long offset)
1131
/* MUST BE 16-BYTE ALIGNED FOR REDCLOUD */
1136
/* SET REGISTER VALUE */
1138
lock = READ_REG32(MDC_UNLOCK);
1139
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1140
WRITE_REG32(MDC_CB_ST_OFFSET, offset & 0x0FFFFFFF);
1141
WRITE_REG32(MDC_UNLOCK, lock);
1146
/*---------------------------------------------------------------------------
1147
* gfx_set_compression_pitch
1149
* This routine sets the pitch, in bytes, of the compression buffer.
1150
*---------------------------------------------------------------------------
1152
#if GFX_DISPLAY_DYNAMIC
1154
gu2_set_compression_pitch(unsigned short pitch)
1157
gfx_set_compression_pitch(unsigned short pitch)
1160
unsigned long lock, line_delta;
1162
lock = READ_REG32(MDC_UNLOCK);
1164
/* SET REGISTER VALUE */
1166
line_delta = READ_REG32(MDC_GFX_PITCH) & 0x0000FFFF;
1167
line_delta |= (((unsigned long) pitch << 13) & 0xFFFF0000);
1168
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1169
WRITE_REG32(MDC_GFX_PITCH, line_delta);
1170
WRITE_REG32(MDC_UNLOCK, lock);
1174
/*---------------------------------------------------------------------------
1175
* gfx_set_compression_size
1177
* This routine sets the line size of the compression buffer, which is the
1178
* maximum number of bytes allowed to store a compressed line.
1179
*---------------------------------------------------------------------------
1181
#if GFX_DISPLAY_DYNAMIC
1183
gu2_set_compression_size(unsigned short size)
1186
gfx_set_compression_size(unsigned short size)
1189
unsigned long lock, buf_size;
1191
/* SUBTRACT 32 FROM SIZE */
1192
/* The display controller will actually write */
1193
/* 4 extra QWords. So, if we assume that "size" */
1194
/* refers to the allocated size, we must subtract */
1199
/* SET REGISTER VALUE */
1201
lock = READ_REG32(MDC_UNLOCK);
1202
buf_size = READ_REG32(MDC_LINE_SIZE) & 0xFF80FFFF;
1203
buf_size |= ((((unsigned long) size >> 3) + 1) & 0x7F) << 16;
1204
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1205
WRITE_REG32(MDC_LINE_SIZE, buf_size);
1206
WRITE_REG32(MDC_UNLOCK, lock);
1210
/*---------------------------------------------------------------------------
1211
* gfx_set_display_video_format (PRIVATE ROUTINE - NOT PART OF API)
1213
* This routine is called by "gfx_set_video_format". It abstracts the
1214
* version of the display controller from the video overlay routines.
1215
*---------------------------------------------------------------------------
1217
#if GFX_DISPLAY_DYNAMIC
1219
gu2_set_display_video_format(unsigned long format)
1222
gfx_set_display_video_format(unsigned long format)
1225
unsigned long gcfg, lock;
1227
lock = READ_REG32(MDC_UNLOCK);
1228
gcfg = READ_REG32(MDC_GENERAL_CFG);
1231
case VIDEO_FORMAT_Y0Y1Y2Y3:
1232
case VIDEO_FORMAT_Y3Y2Y1Y0:
1233
case VIDEO_FORMAT_Y1Y0Y3Y2:
1234
case VIDEO_FORMAT_Y1Y2Y3Y0:
1235
gcfg |= MDC_GCFG_YUVM;
1239
gcfg &= ~MDC_GCFG_YUVM;
1243
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1244
WRITE_REG32(MDC_GENERAL_CFG, gcfg);
1245
WRITE_REG32(MDC_UNLOCK, lock);
1248
/*---------------------------------------------------------------------------
1249
* gfx_set_display_video_enable (PRIVATE ROUTINE - NOT PART OF API)
1251
* This routine is called by "gfx_set_video_enable". It abstracts the
1252
* version of the display controller from the video overlay routines.
1253
*---------------------------------------------------------------------------
1255
#if GFX_DISPLAY_DYNAMIC
1257
gu2_set_display_video_enable(int enable)
1260
gfx_set_display_video_enable(int enable)
1263
unsigned long lock, gcfg, dcfg;
1265
/* READ CURRENT VALUES */
1267
lock = READ_REG32(MDC_UNLOCK);
1268
gcfg = READ_REG32(MDC_GENERAL_CFG);
1269
dcfg = READ_REG32(MDC_DISPLAY_CFG);
1271
/* SET OR CLEAR VIDEO ENABLE IN GENERAL_CFG */
1274
gcfg |= MDC_GCFG_VIDE;
1276
gcfg &= ~MDC_GCFG_VIDE;
1278
/* WRITE REGISTER */
1280
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1281
WRITE_REG32(MDC_GENERAL_CFG, gcfg);
1282
WRITE_REG32(MDC_UNLOCK, lock);
1285
/*---------------------------------------------------------------------------
1286
* gfx_set_display_video_size (PRIVATE ROUTINE - NOT PART OF API)
1288
* This routine is called by "gfx_set_video_size". It abstracts the
1289
* version of the display controller from the video overlay routines.
1290
*---------------------------------------------------------------------------
1292
#if GFX_DISPLAY_DYNAMIC
1294
gu2_set_display_video_size(unsigned short width, unsigned short height)
1297
gfx_set_display_video_size(unsigned short width, unsigned short height)
1300
unsigned long lock, value, yuv_420;
1302
/* READ CURRENT VALUES */
1304
lock = READ_REG32(MDC_UNLOCK);
1305
value = READ_REG32(MDC_LINE_SIZE) & 0x00FFFFFF;
1306
yuv_420 = READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_YUVM;
1308
/* LINE WIDTH IS 1/4 FOR 4:2:0 VIDEO */
1309
/* All data must be 32-byte aligned. */
1313
width = (width + 7) & 0xFFF8;
1317
width = (width + 31) & 0xFFE0;
1320
/* ONLY THE LINE SIZE IS PROGRAMMED IN THE DISPLAY CONTROLLER */
1322
value |= ((unsigned long) width << 21);
1324
/* WRITE THE REGISTER */
1326
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1327
WRITE_REG32(MDC_LINE_SIZE, value);
1328
WRITE_REG32(MDC_UNLOCK, lock);
1331
/*---------------------------------------------------------------------------
1332
* gfx_set_display_video_offset (PRIVATE ROUTINE - NOT PART OF API)
1334
* This routine is called by "gfx_set_video_offset". It abstracts the
1335
* version of the display controller from the video overlay routines.
1336
*---------------------------------------------------------------------------
1338
#if GFX_DISPLAY_DYNAMIC
1340
gu2_set_display_video_offset(unsigned long offset)
1343
gfx_set_display_video_offset(unsigned long offset)
1348
lock = READ_REG32(MDC_UNLOCK);
1349
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1350
offset &= 0x0FFFFFF0;
1351
WRITE_REG32(MDC_VID_Y_ST_OFFSET, offset);
1352
WRITE_REG32(MDC_UNLOCK, lock);
1355
/*---------------------------------------------------------------------------
1356
* gfx_set_display_video_yuv_offsets (PRIVATE ROUTINE - NOT PART OF API)
1358
* This routine is called by gfx_set_video_yuv_offsets. It abstracts the
1359
* version of the display controller from the video overlay routines.
1360
*---------------------------------------------------------------------------
1362
#if GFX_DISPLAY_DYNAMIC
1364
gu2_set_display_video_yuv_offsets(unsigned long yoffset,
1365
unsigned long uoffset, unsigned long voffset)
1368
gfx_set_display_video_yuv_offsets(unsigned long yoffset,
1369
unsigned long uoffset, unsigned long voffset)
1374
lock = READ_REG32(MDC_UNLOCK);
1376
yoffset &= 0x0FFFFFF0;
1377
uoffset &= 0x0FFFFFF8;
1378
voffset &= 0x0FFFFFF8;
1380
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1381
WRITE_REG32(MDC_VID_Y_ST_OFFSET, yoffset);
1382
WRITE_REG32(MDC_VID_U_ST_OFFSET, uoffset);
1383
WRITE_REG32(MDC_VID_V_ST_OFFSET, voffset);
1384
WRITE_REG32(MDC_UNLOCK, lock);
1387
/*---------------------------------------------------------------------------
1388
* gfx_set_display_video_yuv_pitch (PRIVATE ROUTINE - NOT PART OF API)
1390
* This routine is called by gfx_set_video_yuv_pitch. It abstracts the
1391
* version of the display controller from the video overlay routines.
1392
*---------------------------------------------------------------------------
1394
#if GFX_DISPLAY_DYNAMIC
1396
gu2_set_display_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch)
1399
gfx_set_display_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch)
1402
unsigned long lock, pitch;
1404
lock = READ_REG32(MDC_UNLOCK);
1406
pitch = ((uvpitch << 13) & 0xFFFF0000) | ((ypitch >> 3) & 0xFFFF);
1408
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1409
WRITE_REG32(MDC_VID_YUV_PITCH, pitch);
1410
WRITE_REG32(MDC_UNLOCK, lock);
1413
/*---------------------------------------------------------------------------
1414
* gfx_set_display_video_downscale (PRIVATE ROUTINE - NOT PART OF API)
1416
* This routine is called by gfx_set_video_vertical_downscale. It abstracts
1417
* the version of the display controller from the video overlay routines.
1418
*---------------------------------------------------------------------------
1420
#if GFX_DISPLAY_DYNAMIC
1422
gu2_set_display_video_downscale(unsigned short srch, unsigned short dsth)
1425
gfx_set_display_video_downscale(unsigned short srch, unsigned short dsth)
1428
unsigned long lock, delta;
1430
lock = READ_REG32(MDC_UNLOCK);
1432
/* CLIP SCALING LIMITS */
1433
/* Upscaling is performed in a separate function. */
1434
/* Maximum scale ratio is 1/2. */
1436
if (dsth > srch || dsth <= (srch >> 1))
1439
delta = (((unsigned long) srch << 14) / (unsigned long) dsth) << 18;
1441
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1442
WRITE_REG32(MDC_VID_DS_DELTA, delta);
1443
WRITE_REG32(MDC_UNLOCK, lock);
1446
/*---------------------------------------------------------------------------
1447
* gfx_set_display_video_downscale_enable (PRIVATE ROUTINE - NOT PART OF API)
1449
* This routine is called by "gfx_set_video_vertical_downscale_enable".
1450
* It abstracts the version of the display controller from the video overlay
1452
*---------------------------------------------------------------------------
1454
#if GFX_DISPLAY_DYNAMIC
1456
gu2_set_display_video_vertical_downscale_enable(int enable)
1459
gfx_set_display_video_vertical_downscale_enable(int enable)
1462
unsigned long gcfg, unlock;
1464
unlock = READ_REG32(MDC_UNLOCK);
1465
gcfg = READ_REG32(MDC_GENERAL_CFG);
1468
gcfg |= MDC_GCFG_VDSE;
1470
gcfg &= ~MDC_GCFG_VDSE;
1472
WRITE_REG32(MDC_UNLOCK, MDC_UNLOCK_VALUE);
1473
WRITE_REG32(MDC_GENERAL_CFG, gcfg);
1474
WRITE_REG32(MDC_UNLOCK, unlock);
1477
/*---------------------------------------------------------------------------
1478
* gfx_test_timing_active
1479
*---------------------------------------------------------------------------
1481
#if GFX_DISPLAY_DYNAMIC
1483
gu2_test_timing_active(void)
1486
gfx_test_timing_active(void)
1489
if (READ_REG32(MDC_DISPLAY_CFG) & MDC_DCFG_TGEN)
1495
/*---------------------------------------------------------------------------
1496
* gfx_test_vertical_active
1497
*---------------------------------------------------------------------------
1499
#if GFX_DISPLAY_DYNAMIC
1501
gu2_test_vertical_active(void)
1504
gfx_test_vertical_active(void)
1507
if (READ_REG32(MDC_LINE_CNT_STATUS) & MDC_LNCNT_VNA)
1513
/*---------------------------------------------------------------------------
1514
* gfx_wait_vertical_blank
1515
*---------------------------------------------------------------------------
1517
#if GFX_DISPLAY_DYNAMIC
1519
gu2_wait_vertical_blank(void)
1522
gfx_wait_vertical_blank(void)
1525
if (gfx_test_timing_active()) {
1526
while (!gfx_test_vertical_active());
1527
while (gfx_test_vertical_active());
1532
/*---------------------------------------------------------------------------
1533
* gfx_enable_panning
1535
* This routine enables the panning when the Mode is bigger than the panel
1537
*---------------------------------------------------------------------------
1540
#if GFX_DISPLAY_DYNAMIC
1542
gu2_enable_panning(int x, int y)
1545
gfx_enable_panning(int x, int y)
1548
unsigned long modeBytesPerPixel;
1549
unsigned long modeBytesPerScanline = 0;
1550
unsigned long startAddress = 0;
1552
modeBytesPerPixel = (gbpp + 7) / 8;
1553
modeBytesPerScanline = (READ_REG32(MDC_GFX_PITCH) & 0x0000FFFF) << 3;
1555
/* TEST FOR NO-WORK */
1557
if (x >= DeltaX && x < ((int) PanelWidth + DeltaX) &&
1558
y >= DeltaY && y < ((int) PanelHeight + DeltaY))
1561
/* ADJUST PANNING VARIABLES WHEN CURSOR EXCEEDS BOUNDARY */
1562
/* Test the boundary conditions for each coordinate and update */
1563
/* all variables and the starting offset accordingly. */
1568
else if (x >= (DeltaX + (int) PanelWidth))
1569
DeltaX = x - (int) PanelWidth + 1;
1574
else if (y >= (DeltaY + (int) PanelHeight))
1575
DeltaY = y - (int) PanelHeight + 1;
1577
/* CALCULATE THE START OFFSET */
1580
(DeltaX * modeBytesPerPixel) + (DeltaY * modeBytesPerScanline);
1582
gfx_set_display_offset(startAddress);
1584
/* SET PANEL COORDINATES */
1585
/* Panel's x position must be DWORD aligned */
1588
panelLeft = DeltaX * modeBytesPerPixel;
1591
panelLeft = (panelLeft & 0xFFFFFFFC) + 4;
1593
panelLeft /= modeBytesPerPixel;
1596
/*---------------------------------------------------------------------------
1597
* gfx_is_panel_mode_supported
1598
*---------------------------------------------------------------------------
1601
#if GFX_DISPLAY_DYNAMIC
1603
gu2_is_panel_mode_supported(int panelResX, int panelResY,
1604
unsigned short width, unsigned short height,
1608
gfx_is_panel_mode_supported(int panelResX, int panelResY,
1609
unsigned short width, unsigned short height,
1615
/* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */
1616
for (mode = 0; mode < NUM_FIXED_TIMINGS_MODES; mode++) {
1617
if ((FixedParams[mode].xres == width) &&
1618
(FixedParams[mode].yres == height) &&
1619
(FixedParams[mode].panelresx == panelResX) &&
1620
(FixedParams[mode].panelresy == panelResY)) {
1621
return ((int) mode);
1628
/*---------------------------------------------------------------------------
1629
* gfx_set_fixed_timings
1630
*---------------------------------------------------------------------------
1633
#if GFX_DISPLAY_DYNAMIC
1635
gu2_set_fixed_timings(int panelResX, int panelResY, unsigned short width,
1636
unsigned short height, unsigned short bpp)
1639
gfx_set_fixed_timings(int panelResX, int panelResY, unsigned short width,
1640
unsigned short height, unsigned short bpp)
1646
ModeHeight = height;
1647
PanelWidth = (unsigned short) panelResX;
1648
PanelHeight = (unsigned short) panelResY;
1651
/* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */
1652
for (mode = 0; mode < NUM_FIXED_TIMINGS_MODES; mode++) {
1653
if ((FixedParams[mode].xres == width) &&
1654
(FixedParams[mode].yres == height) &&
1655
(FixedParams[mode].panelresx == panelResX) &&
1656
(FixedParams[mode].panelresy == panelResY)) {
1658
/* SET THE 92xx FOR THE SELECTED MODE */
1659
FIXEDTIMINGS *fmode = &FixedParams[mode];
1661
gfx_set_display_timings(bpp, 3, fmode->hactive,
1662
fmode->hblankstart, fmode->hsyncstart,
1663
fmode->hsyncend, fmode->hblankend,
1664
fmode->htotal, fmode->vactive,
1665
fmode->vblankstart, fmode->vsyncstart,
1666
fmode->vsyncend, fmode->vblankend,
1667
fmode->vtotal, fmode->frequency);
1676
/*---------------------------------------------------------------------------
1677
* gfx_set_panel_present
1678
*---------------------------------------------------------------------------
1680
#if GFX_DISPLAY_DYNAMIC
1682
gu2_set_panel_present(int panelResX, int panelResY, unsigned short width,
1683
unsigned short height, unsigned short bpp)
1686
gfx_set_panel_present(int panelResX, int panelResY, unsigned short width,
1687
unsigned short height, unsigned short bpp)
1691
/* 16BPP is the default. */
1693
if (bpp != 8 && bpp != 12 && bpp != 15 && bpp != 16 && bpp != 32)
1696
/* RECORD PANEL PARAMETERS */
1697
/* This routine does not touch any panel timings. It is used when custom
1698
* panel settings are set up in advance by the BIOS or an application, but
1699
* the application still requires access to other panel functionality
1700
* provided by Durango (i.e. panning).
1704
ModeHeight = height;
1705
PanelWidth = (unsigned short) panelResX;
1706
PanelHeight = (unsigned short) panelResY;
1710
/* PROGRAM THE BPP IN THE DISPLAY CONTROLLER */
1712
gfx_set_display_bpp(bpp);
1714
return (GFX_STATUS_OK);
1717
/* THE FOLLOWING READ ROUTINES ARE ALWAYS INCLUDED: */
1719
/*---------------------------------------------------------------------------
1720
* gfx_get_display_pitch
1722
* This routine returns the current pitch of the frame buffer, in bytes.
1723
*---------------------------------------------------------------------------
1725
#if GFX_DISPLAY_DYNAMIC
1727
gu2_get_display_pitch(void)
1730
gfx_get_display_pitch(void)
1733
return ((unsigned short) (READ_REG32(MDC_GFX_PITCH) & 0x0000FFFF) << 3);
1736
/*----------------------------------------------------------------------------
1737
* gfx_mode_frequency_supported
1739
* This routine examines if the requested mode with pixel frequency is
1742
* Returns >0 if successful , <0 if freq. could not be found and matched.
1743
*----------------------------------------------------------------------------
1745
#if GFX_DISPLAY_DYNAMIC
1747
gu2_mode_frequency_supported(int xres, int yres, int bpp,
1748
unsigned long frequency)
1751
gfx_mode_frequency_supported(int xres, int yres, int bpp,
1752
unsigned long frequency)
1756
unsigned long value;
1757
unsigned long bpp_flag = 0;
1759
gfx_mode_bpp_conversion_def(bpp)
1761
for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) {
1762
if ((DisplayParams[index].hactive == (unsigned int) xres) &&
1763
(DisplayParams[index].vactive == (unsigned int) yres) &&
1764
(DisplayParams[index].flags & bpp_flag) &&
1765
(DisplayParams[index].frequency == frequency)) {
1768
value = DisplayParams[index].flags;
1770
if (value & GFX_MODE_56HZ)
1772
else if (value & GFX_MODE_60HZ)
1774
else if (value & GFX_MODE_70HZ)
1776
else if (value & GFX_MODE_72HZ)
1778
else if (value & GFX_MODE_75HZ)
1780
else if (value & GFX_MODE_85HZ)
1782
else if (value & GFX_MODE_90HZ)
1784
else if (value & GFX_MODE_100HZ)
1793
/*----------------------------------------------------------------------------
1794
* gfx_refreshrate_from_frequency
1796
* This routine maps the frequency to close match refresh rate
1797
*----------------------------------------------------------------------------
1799
#if GFX_DISPLAY_DYNAMIC
1801
gu2_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz,
1802
unsigned long frequency)
1805
gfx_get_refreshrate_from_frequency(int xres, int yres, int bpp, int *hz,
1806
unsigned long frequency)
1809
unsigned int index, closematch = 0;
1810
unsigned long value;
1811
unsigned long bpp_flag = 0;
1816
gfx_mode_bpp_conversion_def(bpp)
1818
/* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */
1819
/* Search the table for the closest frequency (16.16 format). */
1821
for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) {
1822
if ((DisplayParams[index].htotal == (unsigned int) xres) &&
1823
(DisplayParams[index].vtotal == (unsigned int) yres) &&
1824
(DisplayParams[index].flags & bpp_flag)) {
1825
diff = (long) frequency - (long) DisplayParams[index].frequency;
1836
value = DisplayParams[closematch].flags;
1838
if (value & GFX_MODE_56HZ)
1840
else if (value & GFX_MODE_60HZ)
1842
else if (value & GFX_MODE_70HZ)
1844
else if (value & GFX_MODE_72HZ)
1846
else if (value & GFX_MODE_75HZ)
1848
else if (value & GFX_MODE_85HZ)
1850
else if (value & GFX_MODE_90HZ)
1852
else if (value & GFX_MODE_100HZ)
1858
/*----------------------------------------------------------------------------
1859
* gfx_refreshrate_from_mode
1861
* This routine is identical to the gfx_get_refreshrate_from_frequency,
1862
* except that the active timing values are compared instead of the total
1863
* values. Some modes (such as 70Hz and 72Hz) may be confused in this routine
1864
*----------------------------------------------------------------------------
1866
#if GFX_DISPLAY_DYNAMIC
1868
gu2_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz,
1869
unsigned long frequency)
1872
gfx_get_refreshrate_from_mode(int xres, int yres, int bpp, int *hz,
1873
unsigned long frequency)
1876
unsigned int index, closematch = 0;
1877
unsigned long value;
1878
unsigned long bpp_flag = 0;
1883
gfx_mode_bpp_conversion_def(bpp)
1885
/* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */
1886
/* Search the table for the closest frequency (16.16 format). */
1888
for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) {
1889
if ((DisplayParams[index].hactive == (unsigned int) xres) &&
1890
(DisplayParams[index].vactive == (unsigned int) yres) &&
1891
(DisplayParams[index].flags & bpp_flag)) {
1892
diff = (long) frequency - (long) DisplayParams[index].frequency;
1903
value = DisplayParams[closematch].flags;
1905
if (value & GFX_MODE_56HZ)
1907
else if (value & GFX_MODE_60HZ)
1909
else if (value & GFX_MODE_70HZ)
1911
else if (value & GFX_MODE_72HZ)
1913
else if (value & GFX_MODE_75HZ)
1915
else if (value & GFX_MODE_85HZ)
1917
else if (value & GFX_MODE_90HZ)
1919
else if (value & GFX_MODE_100HZ)
1925
/*----------------------------------------------------------------------------
1926
* gfx_get_frequency_from_refreshrate
1928
* This routine maps the refresh rate to the closest matching PLL frequency.
1929
*----------------------------------------------------------------------------
1931
#if GFX_DISPLAY_DYNAMIC
1933
gu2_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz,
1937
gfx_get_frequency_from_refreshrate(int xres, int yres, int bpp, int hz,
1943
unsigned long hz_flag = 0;
1944
unsigned long bpp_flag = 0;
1948
gfx_mode_hz_conversion gfx_mode_bpp_conversion_def(bpp)
1950
/* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */
1951
/* Search the table for the closest frequency (16.16 format). */
1952
for (index = 0; index < NUM_RC_DISPLAY_MODES; index++) {
1953
if ((DisplayParams[index].hactive == (unsigned short) xres) &&
1954
(DisplayParams[index].vactive == (unsigned short) yres) &&
1955
(DisplayParams[index].flags & bpp_flag) &&
1956
(DisplayParams[index].flags & hz_flag)) {
1957
*frequency = DisplayParams[index].frequency;
1964
/*---------------------------------------------------------------------------
1965
* gfx_get_max_supported_pixel_clock
1967
* This routine returns the maximum recommended speed for the pixel clock. The
1968
* return value is an integer of the format xxxyyy, where xxx.yyy is the
1969
* maximum floating point pixel clock speed.
1970
*---------------------------------------------------------------------------
1972
#if GFX_DISPLAY_DYNAMIC
1974
gu2_get_max_supported_pixel_clock(void)
1977
gfx_get_max_supported_pixel_clock(void)
1983
/*----------------------------------------------------------------------------
1984
* gfx_get_display_mode
1986
* This routine gets the specified display mode.
1988
* Returns >0 if successful and mode returned, <0 if mode could not be found.
1989
*----------------------------------------------------------------------------
1991
#if GFX_DISPLAY_DYNAMIC
1993
gu2_get_display_mode(int *xres, int *yres, int *bpp, int *hz)
1996
gfx_get_display_mode(int *xres, int *yres, int *bpp, int *hz)
1999
unsigned int mode = 0;
2000
unsigned long pll_freq = 0, bpp_flag = 0;
2002
*xres = gfx_get_hactive();
2003
*yres = gfx_get_vactive();
2004
*bpp = gfx_get_display_bpp();
2005
pll_freq = gfx_get_clock_frequency();
2007
/* SET BPP FLAGS TO LIMIT MODE SELECTION */
2008
gfx_mode_bpp_conversion_def(*bpp)
2010
for (mode = 0; mode < NUM_RC_DISPLAY_MODES; mode++) {
2011
if ((DisplayParams[mode].hactive == (unsigned int) *xres) &&
2012
(DisplayParams[mode].vactive == (unsigned int) *yres) &&
2013
(DisplayParams[mode].frequency == pll_freq) &&
2014
(DisplayParams[mode].flags & bpp_flag)) {
2016
pll_freq = DisplayParams[mode].flags;
2018
if (pll_freq & GFX_MODE_56HZ)
2020
else if (pll_freq & GFX_MODE_60HZ)
2022
else if (pll_freq & GFX_MODE_70HZ)
2024
else if (pll_freq & GFX_MODE_72HZ)
2026
else if (pll_freq & GFX_MODE_75HZ)
2028
else if (pll_freq & GFX_MODE_85HZ)
2030
else if (pll_freq & GFX_MODE_90HZ)
2032
else if (pll_freq & GFX_MODE_100HZ)
2041
/*----------------------------------------------------------------------------
2042
* GFX_GET_DISPLAY_DETAILS
2044
* This routine gets the specified display mode.
2046
* Returns 1 if successful, 0 if mode could not be get.
2047
*----------------------------------------------------------------------------
2049
#if GFX_DISPLAY_DYNAMIC
2051
gu2_get_display_details(unsigned int mode, int *xres, int *yres, int *hz)
2054
gfx_get_display_details(unsigned int mode, int *xres, int *yres, int *hz)
2057
if (mode < NUM_RC_DISPLAY_MODES) {
2058
if (DisplayParams[mode].flags & GFX_MODE_56HZ)
2060
else if (DisplayParams[mode].flags & GFX_MODE_60HZ)
2062
else if (DisplayParams[mode].flags & GFX_MODE_70HZ)
2064
else if (DisplayParams[mode].flags & GFX_MODE_72HZ)
2066
else if (DisplayParams[mode].flags & GFX_MODE_75HZ)
2068
else if (DisplayParams[mode].flags & GFX_MODE_85HZ)
2070
else if (DisplayParams[mode].flags & GFX_MODE_90HZ)
2072
else if (DisplayParams[mode].flags & GFX_MODE_100HZ)
2075
*xres = DisplayParams[mode].hactive;
2076
*yres = DisplayParams[mode].vactive;
2078
if (DisplayParams[mode].flags & GFX_MODE_PIXEL_DOUBLE)
2080
if (DisplayParams[mode].flags & GFX_MODE_LINE_DOUBLE)
2088
/*----------------------------------------------------------------------------
2089
* GFX_GET_DISPLAY_MODE_COUNT
2091
* This routine gets the number of available display modes.
2092
*----------------------------------------------------------------------------
2094
#if GFX_DISPLAY_DYNAMIC
2096
gu2_get_display_mode_count(void)
2099
gfx_get_display_mode_count(void)
2102
return (NUM_RC_DISPLAY_MODES);
2105
/*----------------------------------------------------------------------------
2106
* gfx_get_frame_buffer_line_size
2108
* Returns the current frame buffer line size, in bytes
2109
*----------------------------------------------------------------------------
2111
#if GFX_DISPLAY_DYNAMIC
2113
gu2_get_frame_buffer_line_size(void)
2116
gfx_get_frame_buffer_line_size(void)
2119
return ((READ_REG32(MDC_LINE_SIZE) & 0x7FF) << 3);
2122
/*---------------------------------------------------------------------------
2124
*---------------------------------------------------------------------------
2126
#if GFX_DISPLAY_DYNAMIC
2128
gu2_get_hactive(void)
2131
gfx_get_hactive(void)
2134
return ((unsigned short) ((READ_REG32(MDC_H_ACTIVE_TIMING) & 0x0FF8) + 8));
2137
/*---------------------------------------------------------------------------
2138
* gfx_get_hsync_start
2139
*---------------------------------------------------------------------------
2141
#if GFX_DISPLAY_DYNAMIC
2143
gu2_get_hsync_start(void)
2146
gfx_get_hsync_start(void)
2149
return ((unsigned short) ((READ_REG32(MDC_H_SYNC_TIMING) & 0x0FF8) + 8));
2152
/*---------------------------------------------------------------------------
2154
*---------------------------------------------------------------------------
2156
#if GFX_DISPLAY_DYNAMIC
2158
gu2_get_hsync_end(void)
2161
gfx_get_hsync_end(void)
2164
return ((unsigned short) (((READ_REG32(MDC_H_SYNC_TIMING) >> 16) & 0x0FF8)
2168
/*---------------------------------------------------------------------------
2170
*---------------------------------------------------------------------------
2172
#if GFX_DISPLAY_DYNAMIC
2174
gu2_get_htotal(void)
2177
gfx_get_htotal(void)
2180
return ((unsigned short) (((READ_REG32(MDC_H_ACTIVE_TIMING) >> 16) &
2184
/*---------------------------------------------------------------------------
2186
*---------------------------------------------------------------------------
2188
#if GFX_DISPLAY_DYNAMIC
2190
gu2_get_vactive(void)
2193
gfx_get_vactive(void)
2196
return ((unsigned short) ((READ_REG32(MDC_V_ACTIVE_TIMING) & 0x07FF) + 1));
2199
/*---------------------------------------------------------------------------
2201
*---------------------------------------------------------------------------
2203
#if GFX_DISPLAY_DYNAMIC
2205
gu2_get_vsync_end(void)
2208
gfx_get_vsync_end(void)
2211
return ((unsigned short) (((READ_REG32(MDC_V_SYNC_TIMING) >> 16) & 0x07FF)
2215
/*---------------------------------------------------------------------------
2217
*---------------------------------------------------------------------------
2219
#if GFX_DISPLAY_DYNAMIC
2221
gu2_get_vtotal(void)
2224
gfx_get_vtotal(void)
2227
return ((unsigned short) (((READ_REG32(MDC_V_ACTIVE_TIMING) >> 16) &
2231
/*----------------------------------------------------------------------------
2232
* gfx_get_display_bpp
2234
* This routine returns the current color depth of the active display.
2235
*----------------------------------------------------------------------------
2237
#if GFX_DISPLAY_DYNAMIC
2239
gu2_get_display_bpp(void)
2242
gfx_get_display_bpp(void)
2245
unsigned long dcfg = READ_REG32(MDC_DISPLAY_CFG);
2247
switch ((dcfg & MDC_DCFG_DISP_MODE_MASK) >> 8) {
2253
switch ((dcfg & MDC_DCFG_16BPP_MODE_MASK) >> 10) {
2265
/* INVALID SETTING */
2269
/*---------------------------------------------------------------------------
2271
*---------------------------------------------------------------------------
2273
#if GFX_DISPLAY_DYNAMIC
2281
unsigned short current_scan_line;
2283
/* Read similar value twice to ensure that the value is not
2287
(unsigned short) (READ_REG32(MDC_LINE_CNT_STATUS) &
2288
MDC_LNCNT_V_LINE_CNT);
2289
while (current_scan_line !=
2290
(unsigned short) (READ_REG32(MDC_LINE_CNT_STATUS) &
2291
MDC_LNCNT_V_LINE_CNT));
2293
return (current_scan_line >> 16);
2296
/*-----------------------------------------------------------------------------
2297
* gfx_get_display_offset
2298
*-----------------------------------------------------------------------------
2300
#if GFX_DISPLAY_DYNAMIC
2302
gu2_get_display_offset(void)
2305
gfx_get_display_offset(void)
2308
return (READ_REG32(MDC_FB_ST_OFFSET) & 0x0FFFFFFF);
2311
/*-----------------------------------------------------------------------------
2312
* gfx_get_cursor_offset
2313
*-----------------------------------------------------------------------------
2315
#if GFX_DISPLAY_DYNAMIC
2317
gu2_get_cursor_offset(void)
2320
gfx_get_cursor_offset(void)
2323
return (READ_REG32(MDC_CURS_ST_OFFSET) & 0x0FFFFFFF);
2326
#if GFX_READ_ROUTINES
2328
/*************************************************************/
2329
/* READ ROUTINES | INCLUDED FOR DIAGNOSTIC PURPOSES ONLY */
2330
/*************************************************************/
2332
/*---------------------------------------------------------------------------
2333
* gfx_get_hblank_start
2334
*---------------------------------------------------------------------------
2336
#if GFX_DISPLAY_DYNAMIC
2338
gu2_get_hblank_start(void)
2341
gfx_get_hblank_start(void)
2344
return ((unsigned short) ((READ_REG32(MDC_H_BLANK_TIMING) & 0x0FF8) + 8));
2347
/*---------------------------------------------------------------------------
2348
* gfx_get_hblank_end
2349
*---------------------------------------------------------------------------
2351
#if GFX_DISPLAY_DYNAMIC
2353
gu2_get_hblank_end(void)
2356
gfx_get_hblank_end(void)
2359
return ((unsigned short) (((READ_REG32(MDC_H_BLANK_TIMING) >> 16) & 0x0FF8)
2363
/*---------------------------------------------------------------------------
2364
* gfx_get_vblank_start
2365
*---------------------------------------------------------------------------
2367
#if GFX_DISPLAY_DYNAMIC
2369
gu2_get_vblank_start(void)
2372
gfx_get_vblank_start(void)
2375
return ((unsigned short) ((READ_REG32(MDC_V_BLANK_TIMING) & 0x07FF) + 1));
2378
/*---------------------------------------------------------------------------
2379
* gfx_get_vsync_start
2380
*---------------------------------------------------------------------------
2382
#if GFX_DISPLAY_DYNAMIC
2384
gu2_get_vsync_start(void)
2387
gfx_get_vsync_start(void)
2390
return ((unsigned short) ((READ_REG32(MDC_V_SYNC_TIMING) & 0x07FF) + 1));
2393
/*---------------------------------------------------------------------------
2394
* gfx_get_vblank_end
2395
*---------------------------------------------------------------------------
2397
#if GFX_DISPLAY_DYNAMIC
2399
gu2_get_vblank_end(void)
2402
gfx_get_vblank_end(void)
2405
return ((unsigned short) (((READ_REG32(MDC_V_BLANK_TIMING) >> 16) & 0x07FF)
2409
/*----------------------------------------------------------------------------
2410
* gfx_get_display_palette_entry
2411
*----------------------------------------------------------------------------
2413
#if GFX_DISPLAY_DYNAMIC
2415
gu2_get_display_palette_entry(unsigned long index, unsigned long *palette)
2418
gfx_get_display_palette_entry(unsigned long index, unsigned long *palette)
2422
return GFX_STATUS_BAD_PARAMETER;
2424
WRITE_REG32(MDC_PAL_ADDRESS, index);
2425
*palette = READ_REG32(MDC_PAL_DATA);
2430
/*----------------------------------------------------------------------------
2431
* gfx_get_display_palette
2432
*----------------------------------------------------------------------------
2434
#if GFX_DISPLAY_DYNAMIC
2436
gu2_get_display_palette(unsigned long *palette)
2439
gfx_get_display_palette(unsigned long *palette)
2444
WRITE_REG32(MDC_PAL_ADDRESS, 0);
2445
for (i = 0; i < 256; i++) {
2446
palette[i] = READ_REG32(MDC_PAL_DATA);
2450
/*----------------------------------------------------------------------------
2451
* gfx_get_cursor_enable
2452
*----------------------------------------------------------------------------
2454
#if GFX_DISPLAY_DYNAMIC
2456
gu2_get_cursor_enable(void)
2459
gfx_get_cursor_enable(void)
2462
return (READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_CURE);
2465
/*----------------------------------------------------------------------------
2466
* gfx_get_cursor_position
2467
*----------------------------------------------------------------------------
2469
#if GFX_DISPLAY_DYNAMIC
2471
gu2_get_cursor_position(void)
2474
gfx_get_cursor_position(void)
2477
return ((READ_REG32(MDC_CURSOR_X) & 0x07FF) |
2478
((READ_REG32(MDC_CURSOR_Y) << 16) & 0x07FF0000));
2481
/*----------------------------------------------------------------------------
2482
* gfx_get_cursor_offset
2483
*----------------------------------------------------------------------------
2485
#if GFX_DISPLAY_DYNAMIC
2487
gu2_get_cursor_clip(void)
2490
gfx_get_cursor_clip(void)
2493
return (((READ_REG32(MDC_CURSOR_X) >> 11) & 0x03F) |
2494
((READ_REG32(MDC_CURSOR_Y) << 5) & 0x3F0000));
2497
/*----------------------------------------------------------------------------
2498
* gfx_get_cursor_color
2499
*----------------------------------------------------------------------------
2501
#if GFX_DISPLAY_DYNAMIC
2503
gu2_get_cursor_color(int color)
2506
gfx_get_cursor_color(int color)
2510
WRITE_REG32(MDC_PAL_ADDRESS, 0x101);
2513
WRITE_REG32(MDC_PAL_ADDRESS, 0x100);
2515
return READ_REG32(MDC_PAL_DATA);
2518
/*----------------------------------------------------------------------------
2519
* gfx_get_icon_enable
2520
*----------------------------------------------------------------------------
2522
#if GFX_DISPLAY_DYNAMIC
2524
gu2_get_icon_enable(void)
2527
gfx_get_icon_enable(void)
2530
return (READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_ICNE);
2533
/*----------------------------------------------------------------------------
2534
* gfx_get_icon_offset
2535
*----------------------------------------------------------------------------
2537
#if GFX_DISPLAY_DYNAMIC
2539
gu2_get_icon_offset(void)
2542
gfx_get_icon_offset(void)
2545
return (READ_REG32(MDC_ICON_ST_OFFSET) & 0x0FFFFFFF);
2548
/*----------------------------------------------------------------------------
2549
* gfx_get_icon_position
2550
*----------------------------------------------------------------------------
2552
#if GFX_DISPLAY_DYNAMIC
2554
gu2_get_icon_position(void)
2557
gfx_get_icon_position(void)
2560
return (READ_REG32(MDC_ICON_X) & 0x07FF);
2563
/*----------------------------------------------------------------------------
2564
* gfx_get_icon_color
2565
*----------------------------------------------------------------------------
2567
#if GFX_DISPLAY_DYNAMIC
2569
gu2_get_icon_color(int color)
2572
gfx_get_icon_color(int color)
2578
WRITE_REG32(MDC_PAL_ADDRESS, 0x102 + color);
2580
return READ_REG32(MDC_PAL_DATA);
2583
/*----------------------------------------------------------------------------
2584
* gfx_get_compression_enable
2585
*----------------------------------------------------------------------------
2587
#if GFX_DISPLAY_DYNAMIC
2589
gu2_get_compression_enable(void)
2592
gfx_get_compression_enable(void)
2595
if (READ_REG32(MDC_GENERAL_CFG) & MDC_GCFG_CMPE)
2601
/*----------------------------------------------------------------------------
2602
* gfx_get_compression_offset
2603
*----------------------------------------------------------------------------
2605
#if GFX_DISPLAY_DYNAMIC
2607
gu2_get_compression_offset(void)
2610
gfx_get_compression_offset(void)
2613
return (READ_REG32(MDC_CB_ST_OFFSET) & 0x007FFFFF);
2616
/*----------------------------------------------------------------------------
2617
* gfx_get_compression_pitch
2618
*----------------------------------------------------------------------------
2620
#if GFX_DISPLAY_DYNAMIC
2622
gu2_get_compression_pitch(void)
2625
gfx_get_compression_pitch(void)
2628
unsigned short pitch;
2630
pitch = (unsigned short) (READ_REG32(MDC_GFX_PITCH) >> 16);
2631
return (pitch << 3);
2634
/*----------------------------------------------------------------------------
2635
* gfx_get_compression_size
2636
*----------------------------------------------------------------------------
2638
#if GFX_DISPLAY_DYNAMIC
2640
gu2_get_compression_size(void)
2643
gfx_get_compression_size(void)
2646
unsigned short size;
2648
size = (unsigned short) ((READ_REG32(MDC_LINE_SIZE) >> 16) & 0x7F) - 1;
2649
return ((size << 3) + 32);
2652
/*----------------------------------------------------------------------------
2654
*----------------------------------------------------------------------------
2656
#if GFX_DISPLAY_DYNAMIC
2658
gu2_get_valid_bit(int line)
2661
gfx_get_valid_bit(int line)
2664
unsigned long offset;
2667
offset = READ_REG32(MDC_PHY_MEM_OFFSET) & 0xFF000000;
2670
WRITE_REG32(MDC_PHY_MEM_OFFSET, offset);
2671
valid = (int) READ_REG32(MDC_DV_ACC) & 2;
2678
/*---------------------------------------------------------------------------
2679
* gfx_get_display_video_offset (PRIVATE ROUTINE - NOT PART OF API)
2681
* This routine is called by "gfx_get_video_offset". It abstracts the
2682
* version of the display controller from the video overlay routines.
2683
*---------------------------------------------------------------------------
2685
#if GFX_DISPLAY_DYNAMIC
2687
gu2_get_display_video_offset(void)
2690
gfx_get_display_video_offset(void)
2693
return (READ_REG32(MDC_VID_Y_ST_OFFSET) & 0x0FFFFFFF);
2696
/*---------------------------------------------------------------------------
2697
* gfx_get_display_video_yuv_offsets (PRIVATE ROUTINE - NOT PART OF API)
2699
* This routine is called by "gfx_get_video_yuv_offsets". It abstracts the
2700
* version of the display controller from the video overlay routines.
2701
*---------------------------------------------------------------------------
2703
#if GFX_DISPLAY_DYNAMIC
2705
gu2_get_display_video_yuv_offsets(unsigned long *yoffset,
2706
unsigned long *uoffset,
2707
unsigned long *voffset)
2710
gfx_get_display_video_yuv_offsets(unsigned long *yoffset,
2711
unsigned long *uoffset,
2712
unsigned long *voffset)
2715
*yoffset = (READ_REG32(MDC_VID_Y_ST_OFFSET) & 0x0FFFFFFF);
2716
*uoffset = (READ_REG32(MDC_VID_U_ST_OFFSET) & 0x0FFFFFFF);
2717
*voffset = (READ_REG32(MDC_VID_V_ST_OFFSET) & 0x0FFFFFFF);
2720
/*---------------------------------------------------------------------------
2721
* gfx_get_display_video_yuv_pitch (PRIVATE ROUTINE - NOT PART OF API)
2723
* This routine is called by "gfx_get_video_yuv_pitch". It abstracts the
2724
* version of the display controller from the video overlay routines.
2725
*---------------------------------------------------------------------------
2727
#if GFX_DISPLAY_DYNAMIC
2729
gu2_get_display_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch)
2732
gfx_get_display_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch)
2735
unsigned long pitch = READ_REG32(MDC_VID_YUV_PITCH);
2737
*ypitch = ((pitch & 0xFFFF) << 3);
2738
*uvpitch = (pitch >> 13) & 0x7FFF8;
2741
/*---------------------------------------------------------------------------
2742
* gfx_get_display_video_downscale_delta (PRIVATE ROUTINE - NOT PART OF API)
2744
* This routine is called by "gfx_get_video_downscale_delta". It abstracts the
2745
* version of the display controller from the video overlay routines.
2746
*---------------------------------------------------------------------------
2748
#if GFX_DISPLAY_DYNAMIC
2750
gu2_get_display_video_downscale_delta(void)
2753
gfx_get_display_video_downscale_delta(void)
2756
return (READ_REG32(MDC_VID_DS_DELTA) >> 18);
2759
/*---------------------------------------------------------------------------
2760
* gfx_get_display_video_downscale_enable (PRIVATE ROUTINE - NOT PART OF API)
2762
* This routine is called by "gfx_get_video_vertical_downscale_enable".
2763
* It abstracts the version of the display controller from the video overlay
2765
*---------------------------------------------------------------------------
2767
#if GFX_DISPLAY_DYNAMIC
2769
gu2_get_display_video_downscale_enable(void)
2772
gfx_get_display_video_downscale_enable(void)
2775
return ((int) ((READ_REG32(MDC_GENERAL_CFG) >> 19) & 1));
2778
/*---------------------------------------------------------------------------
2779
* gfx_get_display_video_size (PRIVATE ROUTINE - NOT PART OF API)
2781
* This routine is called by "gfx_get_video_size". It abstracts the
2782
* version of the display controller from the video overlay routines.
2783
*---------------------------------------------------------------------------
2785
#if GFX_DISPLAY_DYNAMIC
2787
gu2_get_display_video_size(void)
2790
gfx_get_display_video_size(void)
2793
/* RETURN THE LINE SIZE, AS THIS IS ALL THAT IS AVAILABLE */
2795
return ((READ_REG32(MDC_LINE_SIZE) >> 21) & 0x000007FF);
2798
#endif /* GFX_READ_ROUTINES */