2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4 * Copyright 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation;
9 * either version 2, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
13 * the implied warranty of MERCHANTABILITY or FITNESS FOR
14 * A PARTICULAR PURPOSE.See the GNU General Public License
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * basic modesetting functions
26 #include <linux/kernel.h>
27 #include <linux/via-core.h>
28 #include "via_modesetting.h"
32 void via_set_primary_address(u32 addr)
34 DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr);
35 via_write_reg(VIACR, 0x0D, addr & 0xFF);
36 via_write_reg(VIACR, 0x0C, (addr >> 8) & 0xFF);
37 via_write_reg(VIACR, 0x34, (addr >> 16) & 0xFF);
38 via_write_reg_mask(VIACR, 0x48, (addr >> 24) & 0x1F, 0x1F);
41 void via_set_secondary_address(u32 addr)
43 DEBUG_MSG(KERN_DEBUG "via_set_secondary_address(0x%08X)\n", addr);
44 /* secondary display supports only quadword aligned memory */
45 via_write_reg_mask(VIACR, 0x62, (addr >> 2) & 0xFE, 0xFE);
46 via_write_reg(VIACR, 0x63, (addr >> 10) & 0xFF);
47 via_write_reg(VIACR, 0x64, (addr >> 18) & 0xFF);
48 via_write_reg_mask(VIACR, 0xA3, (addr >> 26) & 0x07, 0x07);
51 void via_set_primary_pitch(u32 pitch)
53 DEBUG_MSG(KERN_DEBUG "via_set_primary_pitch(0x%08X)\n", pitch);
54 /* spec does not say that first adapter skips 3 bits but old
55 * code did it and seems to be reasonable in analogy to 2nd adapter
58 via_write_reg(VIACR, 0x13, pitch & 0xFF);
59 via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0);
62 void via_set_secondary_pitch(u32 pitch)
64 DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch);
66 via_write_reg(VIACR, 0x66, pitch & 0xFF);
67 via_write_reg_mask(VIACR, 0x67, (pitch >> 8) & 0x03, 0x03);
68 via_write_reg_mask(VIACR, 0x71, (pitch >> (10 - 7)) & 0x80, 0x80);
71 void via_set_primary_color_depth(u8 depth)
75 DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth);
93 printk(KERN_WARNING "via_set_primary_color_depth: "
94 "Unsupported depth: %d\n", depth);
98 via_write_reg_mask(VIASR, 0x15, value, 0x1C);
101 void via_set_secondary_color_depth(u8 depth)
105 DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth);
120 printk(KERN_WARNING "via_set_secondary_color_depth: "
121 "Unsupported depth: %d\n", depth);
125 via_write_reg_mask(VIACR, 0x67, value, 0xC0);