2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE.See the GNU General Public License
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 /* Get frame buffer size from VGA BIOS */
26 unsigned int viafb_get_memsize(void)
30 /* If memory size provided by user */
32 m = viafb_memsize * Mb;
34 m = (unsigned int)viafb_read_reg(VIASR, SR39);
37 if ((m < (16 * Mb)) || (m > (64 * Mb)))
40 DEBUG_MSG(KERN_INFO "framebuffer size = %d Mb\n", m / Mb);
44 /* Get Video Buffer Starting Physical Address(back door)*/
46 unsigned long viafb_get_videobuf_addr(void)
48 struct pci_dev *pdev = NULL;
49 unsigned char sys_mem;
50 unsigned char video_mem;
51 unsigned long sys_mem_size;
52 unsigned long video_mem_size;
53 /*system memory = 256 MB, video memory 64 MB */
54 unsigned long vmem_starting_adr = 0x0C000000;
57 (struct pci_dev *)pci_get_device(VIA_K800_BRIDGE_VID,
58 VIA_K800_BRIDGE_DID, NULL);
60 pci_read_config_byte(pdev, VIA_K800_SYSTEM_MEMORY_REG,
62 pci_read_config_byte(pdev, VIA_K800_VIDEO_MEMORY_REG,
64 video_mem = (video_mem & 0x70) >> 4;
65 sys_mem_size = ((unsigned long)sys_mem) << 24;
67 video_mem_size = (1 << (video_mem)) * 1024 * 1024;
71 vmem_starting_adr = sys_mem_size - video_mem_size;
75 DEBUG_MSG(KERN_INFO "Video Memory Starting Address = %lx \n",
77 return vmem_starting_adr;