Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v3.1 126 lines 3.4 kB view raw
1/* 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> 5 * 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. 10 * 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 15 * for more details. 16 * 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 19 * Foundation, Inc., 20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 */ 22/* 23 * basic modesetting functions 24 */ 25 26#include <linux/kernel.h> 27#include <linux/via-core.h> 28#include "via_modesetting.h" 29#include "share.h" 30#include "debug.h" 31 32void via_set_primary_address(u32 addr) 33{ 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); 39} 40 41void via_set_secondary_address(u32 addr) 42{ 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); 49} 50 51void via_set_primary_pitch(u32 pitch) 52{ 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 56 */ 57 pitch = pitch >> 3; 58 via_write_reg(VIACR, 0x13, pitch & 0xFF); 59 via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0); 60} 61 62void via_set_secondary_pitch(u32 pitch) 63{ 64 DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch); 65 pitch = pitch >> 3; 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); 69} 70 71void via_set_primary_color_depth(u8 depth) 72{ 73 u8 value; 74 75 DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth); 76 switch (depth) { 77 case 8: 78 value = 0x00; 79 break; 80 case 15: 81 value = 0x04; 82 break; 83 case 16: 84 value = 0x14; 85 break; 86 case 24: 87 value = 0x0C; 88 break; 89 case 30: 90 value = 0x08; 91 break; 92 default: 93 printk(KERN_WARNING "via_set_primary_color_depth: " 94 "Unsupported depth: %d\n", depth); 95 return; 96 } 97 98 via_write_reg_mask(VIASR, 0x15, value, 0x1C); 99} 100 101void via_set_secondary_color_depth(u8 depth) 102{ 103 u8 value; 104 105 DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth); 106 switch (depth) { 107 case 8: 108 value = 0x00; 109 break; 110 case 16: 111 value = 0x40; 112 break; 113 case 24: 114 value = 0xC0; 115 break; 116 case 30: 117 value = 0x80; 118 break; 119 default: 120 printk(KERN_WARNING "via_set_secondary_color_depth: " 121 "Unsupported depth: %d\n", depth); 122 return; 123 } 124 125 via_write_reg_mask(VIACR, 0x67, value, 0xC0); 126}