iface.c 2.2 KB

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