1100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat/* 2100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. 3100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. 4100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * Copyright 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> 5100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * 6100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * This program is free software; you can redistribute it and/or 7100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * modify it under the terms of the GNU General Public 8100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * License as published by the Free Software Foundation; 9100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * either version 2, or (at your option) any later version. 10100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * 11100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * This program is distributed in the hope that it will be useful, 12100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even 13100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * the implied warranty of MERCHANTABILITY or FITNESS FOR 14100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * A PARTICULAR PURPOSE.See the GNU General Public License 15100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * for more details. 16100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * 17100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * You should have received a copy of the GNU General Public License 18100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * along with this program; if not, write to the Free Software 19100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * Foundation, Inc., 20100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat */ 22100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat/* 23100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * basic modesetting functions 24100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat */ 25100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 26100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat#include <linux/kernel.h> 27ec66841e495b9ab4f92bdf91efe8cf56e1471fbdJonathan Corbet#include <linux/via-core.h> 28100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat#include "via_modesetting.h" 29100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat#include "share.h" 30100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat#include "debug.h" 31100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 32d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 33ea4f3111ef0daffa1d11fded6f375227febca458Steffen Trumtrarvoid via_set_primary_timing(const struct via_display_timing *timing) 34d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat{ 35ea4f3111ef0daffa1d11fded6f375227febca458Steffen Trumtrar struct via_display_timing raw; 36d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 37d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_total = timing->hor_total / 8 - 5; 38d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_addr = timing->hor_addr / 8 - 1; 39d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_blank_start = timing->hor_blank_start / 8 - 1; 40d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_blank_end = timing->hor_blank_end / 8 - 1; 41d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_sync_start = timing->hor_sync_start / 8; 42d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_sync_end = timing->hor_sync_end / 8; 43d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_total = timing->ver_total - 2; 44d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_addr = timing->ver_addr - 1; 45d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_blank_start = timing->ver_blank_start - 1; 46d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_blank_end = timing->ver_blank_end - 1; 47d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_sync_start = timing->ver_sync_start - 1; 48d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_sync_end = timing->ver_sync_end - 1; 49d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 50d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat /* unlock timing registers */ 51d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x11, 0x00, 0x80); 52d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 53d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x00, raw.hor_total & 0xFF); 54d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x01, raw.hor_addr & 0xFF); 55d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x02, raw.hor_blank_start & 0xFF); 56d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x03, raw.hor_blank_end & 0x1F, 0x1F); 57d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x04, raw.hor_sync_start & 0xFF); 58d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x05, (raw.hor_sync_end & 0x1F) 59d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.hor_blank_end << (7 - 5) & 0x80), 0x9F); 60d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x06, raw.ver_total & 0xFF); 61d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x07, (raw.ver_total >> 8 & 0x01) 62d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_addr >> (8 - 1) & 0x02) 63d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_sync_start >> (8 - 2) & 0x04) 64d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_blank_start >> (8 - 3) & 0x08) 65d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_total >> (9 - 5) & 0x20) 66d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_addr >> (9 - 6) & 0x40) 67d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_sync_start >> (9 - 7) & 0x80), 0xEF); 68d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x09, raw.ver_blank_start >> (9 - 5) & 0x20, 69d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 0x20); 70d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x10, raw.ver_sync_start & 0xFF); 71d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x11, raw.ver_sync_end & 0x0F, 0x0F); 72d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x12, raw.ver_addr & 0xFF); 73d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x15, raw.ver_blank_start & 0xFF); 74d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x16, raw.ver_blank_end & 0xFF); 75d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x33, (raw.hor_sync_start >> (8 - 4) & 0x10) 76d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.hor_blank_end >> (6 - 5) & 0x20), 0x30); 77d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x35, (raw.ver_total >> 10 & 0x01) 78d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_sync_start >> (10 - 1) & 0x02) 79d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_addr >> (10 - 2) & 0x04) 80d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_blank_start >> (10 - 3) & 0x08), 0x0F); 81d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x36, raw.hor_total >> (8 - 3) & 0x08, 0x08); 82d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 83d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat /* lock timing registers */ 84d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x11, 0x80, 0x80); 85c174e3a3cd0594958c9afc6cdb8fbe20780d9c76Florian Tobias Schandinat 86c174e3a3cd0594958c9afc6cdb8fbe20780d9c76Florian Tobias Schandinat /* reset timing control */ 87c174e3a3cd0594958c9afc6cdb8fbe20780d9c76Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x17, 0x00, 0x80); 88c174e3a3cd0594958c9afc6cdb8fbe20780d9c76Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x17, 0x80, 0x80); 89d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat} 90d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 91ea4f3111ef0daffa1d11fded6f375227febca458Steffen Trumtrarvoid via_set_secondary_timing(const struct via_display_timing *timing) 92d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat{ 93ea4f3111ef0daffa1d11fded6f375227febca458Steffen Trumtrar struct via_display_timing raw; 94d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 95d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_total = timing->hor_total - 1; 96d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_addr = timing->hor_addr - 1; 97d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_blank_start = timing->hor_blank_start - 1; 98d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_blank_end = timing->hor_blank_end - 1; 99d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_sync_start = timing->hor_sync_start - 1; 100d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.hor_sync_end = timing->hor_sync_end - 1; 101d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_total = timing->ver_total - 1; 102d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_addr = timing->ver_addr - 1; 103d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_blank_start = timing->ver_blank_start - 1; 104d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_blank_end = timing->ver_blank_end - 1; 105d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_sync_start = timing->ver_sync_start - 1; 106d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat raw.ver_sync_end = timing->ver_sync_end - 1; 107d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 108d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x50, raw.hor_total & 0xFF); 109d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x51, raw.hor_addr & 0xFF); 110d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x52, raw.hor_blank_start & 0xFF); 111d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x53, raw.hor_blank_end & 0xFF); 112d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x54, (raw.hor_blank_start >> 8 & 0x07) 113d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.hor_blank_end >> (8 - 3) & 0x38) 114d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.hor_sync_start >> (8 - 6) & 0xC0)); 115d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x55, (raw.hor_total >> 8 & 0x0F) 116d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.hor_addr >> (8 - 4) & 0x70), 0x7F); 117d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x56, raw.hor_sync_start & 0xFF); 118d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x57, raw.hor_sync_end & 0xFF); 119d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x58, raw.ver_total & 0xFF); 120d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x59, raw.ver_addr & 0xFF); 121d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x5A, raw.ver_blank_start & 0xFF); 122d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x5B, raw.ver_blank_end & 0xFF); 123d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x5C, (raw.ver_blank_start >> 8 & 0x07) 124d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_blank_end >> (8 - 3) & 0x38) 125d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.hor_sync_end >> (8 - 6) & 0x40) 126d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.hor_sync_start >> (10 - 7) & 0x80)); 127d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x5D, (raw.ver_total >> 8 & 0x07) 128d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_addr >> (8 - 3) & 0x38) 129d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.hor_blank_end >> (11 - 6) & 0x40) 130d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.hor_sync_start >> (11 - 7) & 0x80)); 131d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x5E, raw.ver_sync_start & 0xFF); 132d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat via_write_reg(VIACR, 0x5F, (raw.ver_sync_end & 0x1F) 133d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat | (raw.ver_sync_start >> (8 - 5) & 0xE0)); 134d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat} 135d60defb7b2c05b5c4b187171c09b714b0a00efe9Florian Tobias Schandinat 136100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinatvoid via_set_primary_address(u32 addr) 137100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat{ 138100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr); 139100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg(VIACR, 0x0D, addr & 0xFF); 140100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg(VIACR, 0x0C, (addr >> 8) & 0xFF); 141100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg(VIACR, 0x34, (addr >> 16) & 0xFF); 142100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x48, (addr >> 24) & 0x1F, 0x1F); 143100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat} 144100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 145100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinatvoid via_set_secondary_address(u32 addr) 146100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat{ 147100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat DEBUG_MSG(KERN_DEBUG "via_set_secondary_address(0x%08X)\n", addr); 148100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat /* secondary display supports only quadword aligned memory */ 149100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x62, (addr >> 2) & 0xFE, 0xFE); 150100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg(VIACR, 0x63, (addr >> 10) & 0xFF); 151100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg(VIACR, 0x64, (addr >> 18) & 0xFF); 152100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg_mask(VIACR, 0xA3, (addr >> 26) & 0x07, 0x07); 153100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat} 154100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 155100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinatvoid via_set_primary_pitch(u32 pitch) 156100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat{ 157100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat DEBUG_MSG(KERN_DEBUG "via_set_primary_pitch(0x%08X)\n", pitch); 158100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat /* spec does not say that first adapter skips 3 bits but old 159100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat * code did it and seems to be reasonable in analogy to 2nd adapter 160100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat */ 161100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat pitch = pitch >> 3; 162100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg(VIACR, 0x13, pitch & 0xFF); 163100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0); 164100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat} 165100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 166100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinatvoid via_set_secondary_pitch(u32 pitch) 167100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat{ 168100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch); 169100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat pitch = pitch >> 3; 170100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg(VIACR, 0x66, pitch & 0xFF); 171100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x67, (pitch >> 8) & 0x03, 0x03); 172100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x71, (pitch >> (10 - 7)) & 0x80, 0x80); 173100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat} 174100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 175100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinatvoid via_set_primary_color_depth(u8 depth) 176100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat{ 177100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat u8 value; 178100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 179100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth); 180100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat switch (depth) { 181100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat case 8: 182100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat value = 0x00; 183100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat break; 184100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat case 15: 185100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat value = 0x04; 186100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat break; 187100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat case 16: 188100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat value = 0x14; 189100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat break; 190100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat case 24: 191100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat value = 0x0C; 192100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat break; 193100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat case 30: 194100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat value = 0x08; 195100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat break; 196100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat default: 197100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat printk(KERN_WARNING "via_set_primary_color_depth: " 198100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat "Unsupported depth: %d\n", depth); 199100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat return; 200100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat } 201100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 202100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg_mask(VIASR, 0x15, value, 0x1C); 203100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat} 204100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 205100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinatvoid via_set_secondary_color_depth(u8 depth) 206100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat{ 207100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat u8 value; 208100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 209100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth); 210100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat switch (depth) { 211100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat case 8: 212100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat value = 0x00; 213100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat break; 214100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat case 16: 215100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat value = 0x40; 216100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat break; 217100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat case 24: 218100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat value = 0xC0; 219100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat break; 220100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat case 30: 221100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat value = 0x80; 222100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat break; 223100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat default: 224100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat printk(KERN_WARNING "via_set_secondary_color_depth: " 225100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat "Unsupported depth: %d\n", depth); 226100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat return; 227100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat } 228100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat 229100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat via_write_reg_mask(VIACR, 0x67, value, 0xC0); 230100e74a150d3a31d4c12658c926429ceb880d2f7Florian Tobias Schandinat} 231