Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114833
b: refs/heads/master
c: c91b557
h: refs/heads/master
i:
  114831: dcdf4d1
v: v3
  • Loading branch information
Joseph Chan authored and Linus Torvalds committed Oct 16, 2008
1 parent a85bdfe commit 908bbea
Show file tree
Hide file tree
Showing 5 changed files with 439 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d61e0bf38e3e4adb2c775d64e447f6f9bef67075
refs/heads/master: c91b557ad0a4d4803874f8b908aa9732152b0f0b
78 changes: 78 additions & 0 deletions trunk/drivers/video/via/iface.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE.See the GNU General Public License
* for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "global.h"

/* Get frame buffer size from VGA BIOS */

unsigned int viafb_get_memsize(void)
{
unsigned int m;

/* If memory size provided by user */
if (viafb_memsize)
m = viafb_memsize * Mb;
else {
m = (unsigned int)viafb_read_reg(VIASR, SR39);
m = m * (4 * Mb);

if ((m < (16 * Mb)) || (m > (64 * Mb)))
m = 16 * Mb;
}
DEBUG_MSG(KERN_INFO "framebuffer size = %d Mb\n", m / Mb);
return m;
}

/* Get Video Buffer Starting Physical Address(back door)*/

unsigned long viafb_get_videobuf_addr(void)
{
struct pci_dev *pdev = NULL;
unsigned char sys_mem;
unsigned char video_mem;
unsigned long sys_mem_size;
unsigned long video_mem_size;
/*system memory = 256 MB, video memory 64 MB */
unsigned long vmem_starting_adr = 0x0C000000;

pdev =
(struct pci_dev *)pci_get_device(VIA_K800_BRIDGE_VID,
VIA_K800_BRIDGE_DID, NULL);
if (pdev != NULL) {
pci_read_config_byte(pdev, VIA_K800_SYSTEM_MEMORY_REG,
&sys_mem);
pci_read_config_byte(pdev, VIA_K800_VIDEO_MEMORY_REG,
&video_mem);
video_mem = (video_mem & 0x70) >> 4;
sys_mem_size = ((unsigned long)sys_mem) << 24;
if (video_mem != 0)
video_mem_size = (1 << (video_mem)) * 1024 * 1024;
else
video_mem_size = 0;

vmem_starting_adr = sys_mem_size - video_mem_size;
pci_dev_put(pdev);
}

DEBUG_MSG(KERN_INFO "Video Memory Starting Address = %lx \n",
vmem_starting_adr);
return vmem_starting_adr;
}
38 changes: 38 additions & 0 deletions trunk/drivers/video/via/iface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE.See the GNU General Public License
* for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef __IFACE_H__
#define __IFACE_H__

#define Kb (1024)
#define Mb (Kb*Kb)

#define VIA_K800_BRIDGE_VID 0x1106
#define VIA_K800_BRIDGE_DID 0x3204

#define VIA_K800_SYSTEM_MEMORY_REG 0x47
#define VIA_K800_VIDEO_MEMORY_REG 0xA1

extern int viafb_memsize;
unsigned int viafb_get_memsize(void);
unsigned long viafb_get_videobuf_addr(void);

#endif /* __IFACE_H__ */
112 changes: 112 additions & 0 deletions trunk/drivers/video/via/ioctl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE.See the GNU General Public License
* for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "global.h"

int viafb_ioctl_get_viafb_info(u_long arg)
{
struct viafb_ioctl_info viainfo;

viainfo.viafb_id = VIAID;
viainfo.vendor_id = PCI_VIA_VENDOR_ID;

switch (viaparinfo->chip_info->gfx_chip_name) {
case UNICHROME_CLE266:
viainfo.device_id = UNICHROME_CLE266_DID;
break;

case UNICHROME_K400:
viainfo.device_id = UNICHROME_K400_DID;
break;

case UNICHROME_K800:
viainfo.device_id = UNICHROME_K800_DID;
break;

case UNICHROME_PM800:
viainfo.device_id = UNICHROME_PM800_DID;
break;

case UNICHROME_CN700:
viainfo.device_id = UNICHROME_CN700_DID;
break;

case UNICHROME_CX700:
viainfo.device_id = UNICHROME_CX700_DID;
break;

case UNICHROME_K8M890:
viainfo.device_id = UNICHROME_K8M890_DID;
break;

case UNICHROME_P4M890:
viainfo.device_id = UNICHROME_P4M890_DID;
break;

case UNICHROME_P4M900:
viainfo.device_id = UNICHROME_P4M900_DID;
break;
}

viainfo.version = VERSION_MAJOR;
viainfo.revision = VERSION_MINOR;

if (copy_to_user((void __user *)arg, &viainfo, sizeof(viainfo)))
return -EFAULT;

return 0;
}

/* Hot-Plug Priority: DVI > CRT*/
int viafb_ioctl_hotplug(int hres, int vres, int bpp)
{
int DVIsense, status = 0;
DEBUG_MSG(KERN_INFO "viafb_ioctl_hotplug!!\n");

if (viaparinfo->chip_info->tmds_chip_info.tmds_chip_name !=
NON_TMDS_TRANSMITTER) {
DVIsense = viafb_dvi_sense();

if (DVIsense) {
DEBUG_MSG(KERN_INFO "DVI Attached...\n");
if (viafb_DeviceStatus != DVI_Device) {
viafb_DVI_ON = 1;
viafb_CRT_ON = 0;
viafb_LCD_ON = 0;
viafb_DeviceStatus = DVI_Device;
return viafb_DeviceStatus;
}
status = 1;
} else
DEBUG_MSG(KERN_INFO "DVI De-attached...\n");
}

if ((viafb_DeviceStatus != CRT_Device) && (status == 0)) {
viafb_CRT_ON = 1;
viafb_DVI_ON = 0;
viafb_LCD_ON = 0;

viafb_DeviceStatus = CRT_Device;
return viafb_DeviceStatus;
}

return 0;
}
Loading

0 comments on commit 908bbea

Please sign in to comment.