1/*
2 * Copyright 2005-2015 The Openchrome Project
3 *                     [https://www.freedesktop.org/wiki/Openchrome]
4 * Copyright 2004-2005 The Unichrome Project  [unichrome.sf.net]
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sub license,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25
26/*
27 * A big structure with card-ID information, plus some checking functions.
28 */
29
30#ifdef HAVE_CONFIG_H
31#include "config.h"
32#endif
33
34#include "via_driver.h"
35
36static void
37ViaDoubleCheckCLE266Revision(ScrnInfoPtr pScrn)
38{
39    vgaHWPtr hwp = VGAHWPTR(pScrn);
40    VIAPtr pVia = VIAPTR(pScrn);
41    /* Crtc 0x4F is only defined in CLE266Cx */
42    CARD8 tmp = hwp->readCrtc(hwp, 0x4F);
43
44    hwp->writeCrtc(hwp, 0x4F, 0x55);
45    if (hwp->readCrtc(hwp, 0x4F) == 0x55) {
46        if (CLE266_REV_IS_AX(pVia->ChipRev))
47            xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "CLE266 Revision seems"
48                       " to be Cx, yet %d was detected previously.\n",
49                       pVia->ChipRev);
50    } else {
51        if (CLE266_REV_IS_CX(pVia->ChipRev))
52            xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "CLE266 Revision seems"
53                       " to be Ax, yet %d was detected previously.\n",
54                       pVia->ChipRev);
55    }
56    hwp->writeCrtc(hwp, 0x4F, tmp);
57}
58