~ubuntu-branches/ubuntu/trusty/xserver-xorg-video-mach64-lts-xenial/trusty-proposed

« back to all changes in this revision

Viewing changes to src/atimach64io.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2016-05-03 14:02:37 UTC
  • Revision ID: package-import@ubuntu.com-20160503140237-y946gbjc7p6fg9fn
Tags: upstream-6.9.5
ImportĀ upstreamĀ versionĀ 6.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2000 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
 
3
 *
 
4
 * Permission to use, copy, modify, distribute, and sell this software and its
 
5
 * documentation for any purpose is hereby granted without fee, provided that
 
6
 * the above copyright notice appear in all copies and that both that copyright
 
7
 * notice and this permission notice appear in supporting documentation, and
 
8
 * that the name of Marc Aurele La France not be used in advertising or
 
9
 * publicity pertaining to distribution of the software without specific,
 
10
 * written prior permission.  Marc Aurele La France makes no representations
 
11
 * about the suitability of this software for any purpose.  It is provided
 
12
 * "as-is" without express or implied warranty.
 
13
 *
 
14
 * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
15
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
 
16
 * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
17
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
18
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
19
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
20
 * PERFORMANCE OF THIS SOFTWARE.
 
21
 */
 
22
 
 
23
#ifdef HAVE_CONFIG_H
 
24
#include "config.h"
 
25
#endif
 
26
 
 
27
#include "ati.h"
 
28
#include "atichip.h"
 
29
#include "atimach64io.h"
 
30
 
 
31
/*
 
32
 * ATIMach64AccessPLLReg --
 
33
 *
 
34
 * This function sets up the addressing required to access, for read or write,
 
35
 * a 264xT's PLL registers.
 
36
 */
 
37
void
 
38
ATIMach64AccessPLLReg
 
39
(
 
40
    ATIPtr      pATI,
 
41
    const CARD8 Index,
 
42
    const Bool  Write
 
43
)
 
44
{
 
45
    CARD8 clock_cntl1 = in8(CLOCK_CNTL + 1) &
 
46
        ~GetByte(PLL_WR_EN | PLL_ADDR, 1);
 
47
 
 
48
    /* Set PLL register to be read or written */
 
49
    out8(CLOCK_CNTL + 1, clock_cntl1 |
 
50
        GetByte(SetBits(Index, PLL_ADDR) | SetBits(Write, PLL_WR_EN), 1));
 
51
}
 
52
 
 
53
/*
 
54
 * ATIMach64PollEngineStatus --
 
55
 *
 
56
 * This function refreshes the driver's view of the draw engine's status.  This
 
57
 * has been moved into a separate compilation unit to prevent inlining.
 
58
 */
 
59
void
 
60
ATIMach64PollEngineStatus
 
61
(
 
62
    ATIPtr pATI
 
63
)
 
64
{
 
65
    CARD32 IOValue;
 
66
    int    Count;
 
67
 
 
68
    if (pATI->Chip < ATI_CHIP_264VTB)
 
69
    {
 
70
        /*
 
71
         * TODO:  Deal with locked engines.
 
72
         */
 
73
        IOValue = inm(FIFO_STAT);
 
74
        pATI->EngineIsLocked = GetBits(IOValue, FIFO_ERR);
 
75
 
 
76
        /*
 
77
         * The following counts the number of bits in FIFO_STAT_BITS, and is
 
78
         * derived from miSetVisualTypes().
 
79
         */
 
80
        IOValue = GetBits(IOValue, FIFO_STAT_BITS);
 
81
        Count = (IOValue >> 1) & 0x36DBU;
 
82
        Count = IOValue - Count - ((Count >> 1) & 0x36DBU);
 
83
        Count = ((Count + (Count >> 3)) & 0x71C7U) % 0x3FU;
 
84
        Count = pATI->nFIFOEntries - Count;
 
85
        if (Count > pATI->nAvailableFIFOEntries)
 
86
            pATI->nAvailableFIFOEntries = Count;
 
87
 
 
88
        /*
 
89
         * If the command FIFO is non-empty, then the engine isn't idle.
 
90
         */
 
91
        if (pATI->nAvailableFIFOEntries < pATI->nFIFOEntries)
 
92
        {
 
93
            pATI->EngineIsBusy = TRUE;
 
94
            return;
 
95
        }
 
96
    }
 
97
 
 
98
    IOValue = inm(GUI_STAT);
 
99
    pATI->EngineIsBusy = GetBits(IOValue, GUI_ACTIVE);
 
100
    Count = GetBits(IOValue, GUI_FIFO);
 
101
    if (Count > pATI->nAvailableFIFOEntries)
 
102
        pATI->nAvailableFIFOEntries = Count;
 
103
}