Commit 24b4d82e authored by Jonathan Corbet's avatar Jonathan Corbet

viafb: Separate global and fb-specific data

This patch moves data of interest into a new viafb_dev structure which
describes the device as a whole; the idea here is to create a separation
between what all devices may need and what the framebuffer device in
particular needs.

I've also made some small steps toward thinning out the global.h mess.

Cc: ScottFang@viatech.com.cn
Cc: JosephChan@via.com.tw
Cc: Harald Welte <laforge@gnumonks.org>
Acked-by: default avatarFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent f045f77b
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* Foundation, Inc., * Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "via-core.h"
#include "global.h" #include "global.h"
/* /*
...@@ -321,8 +322,7 @@ int viafb_init_engine(struct fb_info *info) ...@@ -321,8 +322,7 @@ int viafb_init_engine(struct fb_info *info)
u32 vq_start_addr, vq_end_addr, vq_start_low, vq_end_low, vq_high, u32 vq_start_addr, vq_end_addr, vq_start_low, vq_end_low, vq_high,
vq_len, chip_name = viapar->shared->chip_info.gfx_chip_name; vq_len, chip_name = viapar->shared->chip_info.gfx_chip_name;
engine = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); engine = viapar->shared->vdev->engine_mmio;
viapar->shared->engine_mmio = engine;
if (!engine) { if (!engine) {
printk(KERN_WARNING "viafb_init_accel: ioremap failed, " printk(KERN_WARNING "viafb_init_accel: ioremap failed, "
"hardware acceleration disabled\n"); "hardware acceleration disabled\n");
...@@ -465,7 +465,7 @@ void viafb_show_hw_cursor(struct fb_info *info, int Status) ...@@ -465,7 +465,7 @@ void viafb_show_hw_cursor(struct fb_info *info, int Status)
struct viafb_par *viapar = info->par; struct viafb_par *viapar = info->par;
u32 temp, iga_path = viapar->iga_path; u32 temp, iga_path = viapar->iga_path;
temp = readl(viapar->shared->engine_mmio + VIA_REG_CURSOR_MODE); temp = readl(viapar->shared->vdev->engine_mmio + VIA_REG_CURSOR_MODE);
switch (Status) { switch (Status) {
case HW_Cursor_ON: case HW_Cursor_ON:
temp |= 0x1; temp |= 0x1;
...@@ -482,7 +482,7 @@ void viafb_show_hw_cursor(struct fb_info *info, int Status) ...@@ -482,7 +482,7 @@ void viafb_show_hw_cursor(struct fb_info *info, int Status)
default: default:
temp &= 0x7FFFFFFF; temp &= 0x7FFFFFFF;
} }
writel(temp, viapar->shared->engine_mmio + VIA_REG_CURSOR_MODE); writel(temp, viapar->shared->vdev->engine_mmio + VIA_REG_CURSOR_MODE);
} }
void viafb_wait_engine_idle(struct fb_info *info) void viafb_wait_engine_idle(struct fb_info *info)
...@@ -490,6 +490,7 @@ void viafb_wait_engine_idle(struct fb_info *info) ...@@ -490,6 +490,7 @@ void viafb_wait_engine_idle(struct fb_info *info)
struct viafb_par *viapar = info->par; struct viafb_par *viapar = info->par;
int loop = 0; int loop = 0;
u32 mask; u32 mask;
void __iomem *engine = viapar->shared->vdev->engine_mmio;
switch (viapar->shared->chip_info.twod_engine) { switch (viapar->shared->chip_info.twod_engine) {
case VIA_2D_ENG_H5: case VIA_2D_ENG_H5:
...@@ -498,7 +499,7 @@ void viafb_wait_engine_idle(struct fb_info *info) ...@@ -498,7 +499,7 @@ void viafb_wait_engine_idle(struct fb_info *info)
VIA_3D_ENG_BUSY_M1; VIA_3D_ENG_BUSY_M1;
break; break;
default: default:
while (!(readl(viapar->shared->engine_mmio + VIA_REG_STATUS) & while (!(readl(engine + VIA_REG_STATUS) &
VIA_VR_QUEUE_BUSY) && (loop < MAXLOOP)) { VIA_VR_QUEUE_BUSY) && (loop < MAXLOOP)) {
loop++; loop++;
cpu_relax(); cpu_relax();
...@@ -507,8 +508,7 @@ void viafb_wait_engine_idle(struct fb_info *info) ...@@ -507,8 +508,7 @@ void viafb_wait_engine_idle(struct fb_info *info)
break; break;
} }
while ((readl(viapar->shared->engine_mmio + VIA_REG_STATUS) & mask) && while ((readl(engine + VIA_REG_STATUS) & mask) && (loop < MAXLOOP)) {
(loop < MAXLOOP)) {
loop++; loop++;
cpu_relax(); cpu_relax();
} }
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
* Foundation, Inc., * Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "via-core.h"
#include "via_i2c.h"
#include "global.h" #include "global.h"
static void tmds_register_write(int index, u8 data); static void tmds_register_write(int index, u8 data);
......
...@@ -35,14 +35,12 @@ ...@@ -35,14 +35,12 @@
#include "debug.h" #include "debug.h"
#include "via-core.h"
#include "viafbdev.h" #include "viafbdev.h"
#include "chip.h" #include "chip.h"
#include "accel.h" #include "accel.h"
#include "share.h" #include "share.h"
#include "dvi.h" #include "dvi.h"
#include "viamode.h" #include "viamode.h"
#include "via_i2c.h"
#include "hw.h" #include "hw.h"
#include "lcd.h" #include "lcd.h"
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* Foundation, Inc., * Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "via-core.h"
#include "global.h" #include "global.h"
static struct pll_map pll_value[] = { static struct pll_map pll_value[] = {
...@@ -526,8 +526,7 @@ static void dvi_patch_skew_dvp_low(void); ...@@ -526,8 +526,7 @@ static void dvi_patch_skew_dvp_low(void);
static void set_dvi_output_path(int set_iga, int output_interface); static void set_dvi_output_path(int set_iga, int output_interface);
static void set_lcd_output_path(int set_iga, int output_interface); static void set_lcd_output_path(int set_iga, int output_interface);
static void load_fix_bit_crtc_reg(void); static void load_fix_bit_crtc_reg(void);
static void init_gfx_chip_info(struct pci_dev *pdev, static void init_gfx_chip_info(int chip_type);
const struct pci_device_id *pdi);
static void init_tmds_chip_info(void); static void init_tmds_chip_info(void);
static void init_lvds_chip_info(void); static void init_lvds_chip_info(void);
static void device_screen_off(void); static void device_screen_off(void);
...@@ -1911,10 +1910,9 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, ...@@ -1911,10 +1910,9 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
} }
void viafb_init_chip_info(struct pci_dev *pdev, void viafb_init_chip_info(int chip_type)
const struct pci_device_id *pdi)
{ {
init_gfx_chip_info(pdev, pdi); init_gfx_chip_info(chip_type);
init_tmds_chip_info(); init_tmds_chip_info();
init_lvds_chip_info(); init_lvds_chip_info();
...@@ -1981,12 +1979,11 @@ void viafb_update_device_setting(int hres, int vres, ...@@ -1981,12 +1979,11 @@ void viafb_update_device_setting(int hres, int vres,
} }
} }
static void init_gfx_chip_info(struct pci_dev *pdev, static void init_gfx_chip_info(int chip_type)
const struct pci_device_id *pdi)
{ {
u8 tmp; u8 tmp;
viaparinfo->chip_info->gfx_chip_name = pdi->driver_data; viaparinfo->chip_info->gfx_chip_name = chip_type;
/* Check revision of CLE266 Chip */ /* Check revision of CLE266 Chip */
if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
...@@ -2489,122 +2486,6 @@ static void disable_second_display_channel(void) ...@@ -2489,122 +2486,6 @@ static void disable_second_display_channel(void)
viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6); viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6);
} }
static u_int16_t via_function3[] = {
CLE266_FUNCTION3, KM400_FUNCTION3, CN400_FUNCTION3, CN700_FUNCTION3,
CX700_FUNCTION3, KM800_FUNCTION3, KM890_FUNCTION3, P4M890_FUNCTION3,
P4M900_FUNCTION3, VX800_FUNCTION3, VX855_FUNCTION3,
};
/* Get the BIOS-configured framebuffer size from PCI configuration space
* of function 3 in the respective chipset */
int viafb_get_fb_size_from_pci(void)
{
int i;
u_int8_t offset = 0;
u_int32_t FBSize;
u_int32_t VideoMemSize;
/* search for the "FUNCTION3" device in this chipset */
for (i = 0; i < ARRAY_SIZE(via_function3); i++) {
struct pci_dev *pdev;
pdev = pci_get_device(PCI_VENDOR_ID_VIA, via_function3[i],
NULL);
if (!pdev)
continue;
DEBUG_MSG(KERN_INFO "Device ID = %x\n", pdev->device);
switch (pdev->device) {
case CLE266_FUNCTION3:
case KM400_FUNCTION3:
offset = 0xE0;
break;
case CN400_FUNCTION3:
case CN700_FUNCTION3:
case CX700_FUNCTION3:
case KM800_FUNCTION3:
case KM890_FUNCTION3:
case P4M890_FUNCTION3:
case P4M900_FUNCTION3:
case VX800_FUNCTION3:
case VX855_FUNCTION3:
/*case CN750_FUNCTION3: */
offset = 0xA0;
break;
}
if (!offset)
break;
pci_read_config_dword(pdev, offset, &FBSize);
pci_dev_put(pdev);
}
if (!offset) {
printk(KERN_ERR "cannot determine framebuffer size\n");
return -EIO;
}
FBSize = FBSize & 0x00007000;
DEBUG_MSG(KERN_INFO "FB Size = %x\n", FBSize);
if (viaparinfo->chip_info->gfx_chip_name < UNICHROME_CX700) {
switch (FBSize) {
case 0x00004000:
VideoMemSize = (16 << 20); /*16M */
break;
case 0x00005000:
VideoMemSize = (32 << 20); /*32M */
break;
case 0x00006000:
VideoMemSize = (64 << 20); /*64M */
break;
default:
VideoMemSize = (32 << 20); /*32M */
break;
}
} else {
switch (FBSize) {
case 0x00001000:
VideoMemSize = (8 << 20); /*8M */
break;
case 0x00002000:
VideoMemSize = (16 << 20); /*16M */
break;
case 0x00003000:
VideoMemSize = (32 << 20); /*32M */
break;
case 0x00004000:
VideoMemSize = (64 << 20); /*64M */
break;
case 0x00005000:
VideoMemSize = (128 << 20); /*128M */
break;
case 0x00006000:
VideoMemSize = (256 << 20); /*256M */
break;
case 0x00007000: /* Only on VX855/875 */
VideoMemSize = (512 << 20); /*512M */
break;
default:
VideoMemSize = (32 << 20); /*32M */
break;
}
}
return VideoMemSize;
}
void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
*p_gfx_dpa_setting) *p_gfx_dpa_setting)
......
...@@ -900,15 +900,13 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp, ...@@ -900,15 +900,13 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
struct VideoModeTable *vmode_tbl1, int video_bpp1); struct VideoModeTable *vmode_tbl1, int video_bpp1);
void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh,
struct VideoModeTable *vmode_tbl); struct VideoModeTable *vmode_tbl);
void viafb_init_chip_info(struct pci_dev *pdev, void viafb_init_chip_info(int chip_type);
const struct pci_device_id *pdi);
void viafb_init_dac(int set_iga); void viafb_init_dac(int set_iga);
int viafb_get_pixclock(int hres, int vres, int vmode_refresh); int viafb_get_pixclock(int hres, int vres, int vmode_refresh);
int viafb_get_refresh(int hres, int vres, u32 float_refresh); int viafb_get_refresh(int hres, int vres, u32 float_refresh);
void viafb_update_device_setting(int hres, int vres, int bpp, void viafb_update_device_setting(int hres, int vres, int bpp,
int vmode_refresh, int flag); int vmode_refresh, int flag);
int viafb_get_fb_size_from_pci(void);
void viafb_set_iga_path(void); void viafb_set_iga_path(void);
void viafb_set_primary_address(u32 addr); void viafb_set_primary_address(u32 addr);
void viafb_set_secondary_address(u32 addr); void viafb_set_secondary_address(u32 addr);
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
* Foundation, Inc., * Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "via-core.h"
#include "via_i2c.h"
#include "global.h" #include "global.h"
#include "lcdtbl.h" #include "lcdtbl.h"
......
...@@ -7,9 +7,12 @@ ...@@ -7,9 +7,12 @@
/* /*
* Core code for the Via multifunction framebuffer device. * Core code for the Via multifunction framebuffer device.
*/ */
#include "via-core.h"
#include "via_i2c.h"
#include "global.h"
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include "global.h" /* Includes everything under the sun */
/* /*
* The default port config. * The default port config.
...@@ -23,6 +26,169 @@ static struct via_port_cfg adap_configs[] = { ...@@ -23,6 +26,169 @@ static struct via_port_cfg adap_configs[] = {
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
/*
* We currently only support one viafb device (will there ever be
* more than one?), so just declare it globally here.
*/
static struct viafb_dev global_dev;
/*
* Figure out how big our framebuffer memory is. Kind of ugly,
* but evidently we can't trust the information found in the
* fbdev configuration area.
*/
static u16 via_function3[] = {
CLE266_FUNCTION3, KM400_FUNCTION3, CN400_FUNCTION3, CN700_FUNCTION3,
CX700_FUNCTION3, KM800_FUNCTION3, KM890_FUNCTION3, P4M890_FUNCTION3,
P4M900_FUNCTION3, VX800_FUNCTION3, VX855_FUNCTION3,
};
/* Get the BIOS-configured framebuffer size from PCI configuration space
* of function 3 in the respective chipset */
static int viafb_get_fb_size_from_pci(int chip_type)
{
int i;
u8 offset = 0;
u32 FBSize;
u32 VideoMemSize;
/* search for the "FUNCTION3" device in this chipset */
for (i = 0; i < ARRAY_SIZE(via_function3); i++) {
struct pci_dev *pdev;
pdev = pci_get_device(PCI_VENDOR_ID_VIA, via_function3[i],
NULL);
if (!pdev)
continue;
DEBUG_MSG(KERN_INFO "Device ID = %x\n", pdev->device);
switch (pdev->device) {
case CLE266_FUNCTION3:
case KM400_FUNCTION3:
offset = 0xE0;
break;
case CN400_FUNCTION3:
case CN700_FUNCTION3:
case CX700_FUNCTION3:
case KM800_FUNCTION3:
case KM890_FUNCTION3:
case P4M890_FUNCTION3:
case P4M900_FUNCTION3:
case VX800_FUNCTION3:
case VX855_FUNCTION3:
/*case CN750_FUNCTION3: */
offset = 0xA0;
break;
}
if (!offset)
break;
pci_read_config_dword(pdev, offset, &FBSize);
pci_dev_put(pdev);
}
if (!offset) {
printk(KERN_ERR "cannot determine framebuffer size\n");
return -EIO;
}
FBSize = FBSize & 0x00007000;
DEBUG_MSG(KERN_INFO "FB Size = %x\n", FBSize);
if (chip_type < UNICHROME_CX700) {
switch (FBSize) {
case 0x00004000:
VideoMemSize = (16 << 20); /*16M */
break;
case 0x00005000:
VideoMemSize = (32 << 20); /*32M */
break;
case 0x00006000:
VideoMemSize = (64 << 20); /*64M */
break;
default:
VideoMemSize = (32 << 20); /*32M */
break;
}
} else {
switch (FBSize) {
case 0x00001000:
VideoMemSize = (8 << 20); /*8M */
break;
case 0x00002000:
VideoMemSize = (16 << 20); /*16M */
break;
case 0x00003000:
VideoMemSize = (32 << 20); /*32M */
break;
case 0x00004000:
VideoMemSize = (64 << 20); /*64M */
break;
case 0x00005000:
VideoMemSize = (128 << 20); /*128M */
break;
case 0x00006000:
VideoMemSize = (256 << 20); /*256M */
break;
case 0x00007000: /* Only on VX855/875 */
VideoMemSize = (512 << 20); /*512M */
break;
default:
VideoMemSize = (32 << 20); /*32M */
break;
}
}
return VideoMemSize;
}
/*
* Figure out and map our MMIO regions.
*/
static int __devinit via_pci_setup_mmio(struct viafb_dev *vdev)
{
/*
* Hook up to the device registers.
*/
vdev->engine_start = pci_resource_start(vdev->pdev, 1);
vdev->engine_len = pci_resource_len(vdev->pdev, 1);
/* If this fails, others will notice later */
vdev->engine_mmio = ioremap_nocache(vdev->engine_start,
vdev->engine_len);
/*
* Likewise with I/O memory.
*/
vdev->fbmem_start = pci_resource_start(vdev->pdev, 0);
vdev->fbmem_len = viafb_get_fb_size_from_pci(vdev->chip_type);
if (vdev->fbmem_len < 0)
return vdev->fbmem_len;
vdev->fbmem = ioremap_nocache(vdev->fbmem_start, vdev->fbmem_len);
if (vdev->fbmem == NULL)
return -ENOMEM;
return 0;
}
static void __devexit via_pci_teardown_mmio(struct viafb_dev *vdev)
{
iounmap(vdev->fbmem);
iounmap(vdev->engine_mmio);
}
static int __devinit via_pci_probe(struct pci_dev *pdev, static int __devinit via_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
...@@ -32,23 +198,35 @@ static int __devinit via_pci_probe(struct pci_dev *pdev, ...@@ -32,23 +198,35 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
ret = pci_enable_device(pdev); ret = pci_enable_device(pdev);
if (ret) if (ret)
return ret; return ret;
/*
* Global device initialization.
*/
memset(&global_dev, 0, sizeof(global_dev));
global_dev.pdev = pdev;
global_dev.chip_type = ent->driver_data;
spin_lock_init(&global_dev.reg_lock);
ret = via_pci_setup_mmio(&global_dev);
if (ret)
goto out_disable;
/* /*
* Create the I2C busses. Bailing out on failure seems extreme, * Create the I2C busses. Bailing out on failure seems extreme,
* but that's what the code did before. * but that's what the code did before.
*/ */
ret = viafb_create_i2c_busses(adap_configs); ret = viafb_create_i2c_busses(adap_configs);
if (ret) if (ret)
goto out_disable; goto out_teardown;
/* /*
* Set up the framebuffer. * Set up the framebuffer.
*/ */
ret = via_fb_pci_probe(pdev, ent); ret = via_fb_pci_probe(&global_dev);
if (ret) if (ret)
goto out_i2c; goto out_i2c;
return 0; return 0;
out_i2c: out_i2c:
viafb_delete_i2c_busses(); viafb_delete_i2c_busses();
out_teardown:
via_pci_teardown_mmio(&global_dev);
out_disable: out_disable:
pci_disable_device(pdev); pci_disable_device(pdev);
return ret; return ret;
...@@ -58,6 +236,7 @@ static void __devexit via_pci_remove(struct pci_dev *pdev) ...@@ -58,6 +236,7 @@ static void __devexit via_pci_remove(struct pci_dev *pdev)
{ {
viafb_delete_i2c_busses(); viafb_delete_i2c_busses();
via_fb_pci_remove(pdev); via_fb_pci_remove(pdev);
via_pci_teardown_mmio(&global_dev);
pci_disable_device(pdev); pci_disable_device(pdev);
} }
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#ifndef __VIA_CORE_H__ #ifndef __VIA_CORE_H__
#define __VIA_CORE_H__ #define __VIA_CORE_H__
#include <linux/spinlock.h>
#include <linux/pci.h>
/* /*
* A description of each known serial I2C/GPIO port. * A description of each known serial I2C/GPIO port.
*/ */
...@@ -49,7 +52,38 @@ enum viafb_i2c_adap { ...@@ -49,7 +52,38 @@ enum viafb_i2c_adap {
struct via_port_cfg { struct via_port_cfg {
enum via_port_type type; enum via_port_type type;
enum via_port_mode mode; enum via_port_mode mode;
u_int16_t io_port; u16 io_port;
u_int8_t ioport_index; u8 ioport_index;
}; };
/*
* This is the global viafb "device" containing stuff needed by
* all subdevs.
*/
struct viafb_dev {
struct pci_dev *pdev;
int chip_type;
/*
* Spinlock for access to device registers. Not yet
* globally used.
*/
spinlock_t reg_lock;
/*
* The framebuffer MMIO region. Little, if anything, touches
* this memory directly, and certainly nothing outside of the
* framebuffer device itself. We *do* have to be able to allocate
* chunks of this memory for other devices, though.
*/
unsigned long fbmem_start;
long fbmem_len;
void __iomem *fbmem;
/*
* The MMIO region for device registers.
*/
unsigned long engine_start;
unsigned long engine_len;
void __iomem *engine_mmio;
};
#endif /* __VIA_CORE_H__ */ #endif /* __VIA_CORE_H__ */
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "via-core.h"
#include "via_i2c.h"
#include "global.h" #include "global.h"
/* /*
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/stat.h> #include <linux/stat.h>
#define _MASTER_FILE #define _MASTER_FILE
#include "via-core.h"
#include "global.h" #include "global.h"
static char *viafb_name = "Via"; static char *viafb_name = "Via";
...@@ -220,7 +221,7 @@ static int viafb_check_var(struct fb_var_screeninfo *var, ...@@ -220,7 +221,7 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
/* Adjust var according to our driver's own table */ /* Adjust var according to our driver's own table */
viafb_fill_var_timing_info(var, viafb_refresh, vmode_entry); viafb_fill_var_timing_info(var, viafb_refresh, vmode_entry);
if (info->var.accel_flags & FB_ACCELF_TEXT && if (info->var.accel_flags & FB_ACCELF_TEXT &&
!ppar->shared->engine_mmio) !ppar->shared->vdev->engine_mmio)
info->var.accel_flags = 0; info->var.accel_flags = 0;
return 0; return 0;
...@@ -695,7 +696,7 @@ static void viafb_fillrect(struct fb_info *info, ...@@ -695,7 +696,7 @@ static void viafb_fillrect(struct fb_info *info,
rop = 0xF0; rop = 0xF0;
DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n"); DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n");
if (shared->hw_bitblt(shared->engine_mmio, VIA_BITBLT_FILL, if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_FILL,
rect->width, rect->height, info->var.bits_per_pixel, rect->width, rect->height, info->var.bits_per_pixel,
viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy, viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy,
NULL, 0, 0, 0, 0, fg_color, 0, rop)) NULL, 0, 0, 0, 0, fg_color, 0, rop))
...@@ -717,7 +718,7 @@ static void viafb_copyarea(struct fb_info *info, ...@@ -717,7 +718,7 @@ static void viafb_copyarea(struct fb_info *info,
return; return;
DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n"); DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n");
if (shared->hw_bitblt(shared->engine_mmio, VIA_BITBLT_COLOR, if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_COLOR,
area->width, area->height, info->var.bits_per_pixel, area->width, area->height, info->var.bits_per_pixel,
viapar->vram_addr, info->fix.line_length, area->dx, area->dy, viapar->vram_addr, info->fix.line_length, area->dx, area->dy,
NULL, viapar->vram_addr, info->fix.line_length, NULL, viapar->vram_addr, info->fix.line_length,
...@@ -754,7 +755,7 @@ static void viafb_imageblit(struct fb_info *info, ...@@ -754,7 +755,7 @@ static void viafb_imageblit(struct fb_info *info,
op = VIA_BITBLT_COLOR; op = VIA_BITBLT_COLOR;
DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n"); DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n");
if (shared->hw_bitblt(shared->engine_mmio, op, if (shared->hw_bitblt(shared->vdev->engine_mmio, op,
image->width, image->height, info->var.bits_per_pixel, image->width, image->height, info->var.bits_per_pixel,
viapar->vram_addr, info->fix.line_length, image->dx, image->dy, viapar->vram_addr, info->fix.line_length, image->dx, image->dy,
(u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0)) (u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0))
...@@ -764,7 +765,7 @@ static void viafb_imageblit(struct fb_info *info, ...@@ -764,7 +765,7 @@ static void viafb_imageblit(struct fb_info *info,
static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor) static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
{ {
struct viafb_par *viapar = info->par; struct viafb_par *viapar = info->par;
void __iomem *engine = viapar->shared->engine_mmio; void __iomem *engine = viapar->shared->vdev->engine_mmio;
u32 temp, xx, yy, bg_color = 0, fg_color = 0, u32 temp, xx, yy, bg_color = 0, fg_color = 0,
chip_name = viapar->shared->chip_info.gfx_chip_name; chip_name = viapar->shared->chip_info.gfx_chip_name;
int i, j = 0, cur_size = 64; int i, j = 0, cur_size = 64;
...@@ -1732,8 +1733,7 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres) ...@@ -1732,8 +1733,7 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres)
} }
int __devinit via_fb_pci_probe(struct pci_dev *pdev, int __devinit via_fb_pci_probe(struct viafb_dev *vdev)
const struct pci_device_id *ent)
{ {
u32 default_xres, default_yres; u32 default_xres, default_yres;
struct VideoModeTable *vmode_entry; struct VideoModeTable *vmode_entry;
...@@ -1750,7 +1750,7 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev, ...@@ -1750,7 +1750,7 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev,
*/ */
viafbinfo = framebuffer_alloc(viafb_par_length + viafbinfo = framebuffer_alloc(viafb_par_length +
ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8), ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8),
&pdev->dev); &vdev->pdev->dev);
if (!viafbinfo) { if (!viafbinfo) {
printk(KERN_ERR"Could not allocate memory for viafb_info.\n"); printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
return -ENOMEM; return -ENOMEM;
...@@ -1758,6 +1758,7 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev, ...@@ -1758,6 +1758,7 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev,
viaparinfo = (struct viafb_par *)viafbinfo->par; viaparinfo = (struct viafb_par *)viafbinfo->par;
viaparinfo->shared = viafbinfo->par + viafb_par_length; viaparinfo->shared = viafbinfo->par + viafb_par_length;
viaparinfo->shared->vdev = vdev;
viaparinfo->vram_addr = 0; viaparinfo->vram_addr = 0;
viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info; viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info;
viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info; viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info;
...@@ -1765,7 +1766,6 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev, ...@@ -1765,7 +1766,6 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev,
&viaparinfo->shared->lvds_setting_info2; &viaparinfo->shared->lvds_setting_info2;
viaparinfo->crt_setting_info = &viaparinfo->shared->crt_setting_info; viaparinfo->crt_setting_info = &viaparinfo->shared->crt_setting_info;
viaparinfo->chip_info = &viaparinfo->shared->chip_info; viaparinfo->chip_info = &viaparinfo->shared->chip_info;
spin_lock_init(&viaparinfo->reg_lock);
if (viafb_dual_fb) if (viafb_dual_fb)
viafb_SAMM_ON = 1; viafb_SAMM_ON = 1;
...@@ -1776,25 +1776,20 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev, ...@@ -1776,25 +1776,20 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev,
if (!viafb_SAMM_ON) if (!viafb_SAMM_ON)
viafb_dual_fb = 0; viafb_dual_fb = 0;
viafb_init_chip_info(pdev, ent); viafb_init_chip_info(vdev->chip_type);
viaparinfo->fbmem = pci_resource_start(pdev, 0); /*
viaparinfo->memsize = viafb_get_fb_size_from_pci(); * The framebuffer will have been successfully mapped by
if (viaparinfo->memsize < 0) { * the core (or we'd not be here), but we still need to
rc = viaparinfo->memsize; * set up our own accounting.
goto out_fb_release; */
} viaparinfo->fbmem = vdev->fbmem_start;
viaparinfo->memsize = vdev->fbmem_len;
viaparinfo->fbmem_free = viaparinfo->memsize; viaparinfo->fbmem_free = viaparinfo->memsize;
viaparinfo->fbmem_used = 0; viaparinfo->fbmem_used = 0;
viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem, viafbinfo->screen_base = vdev->fbmem;
viaparinfo->memsize);
if (!viafbinfo->screen_base) {
printk(KERN_ERR "ioremap of fbmem failed\n");
rc = -ENOMEM;
goto out_fb_release;
}
viafbinfo->fix.mmio_start = pci_resource_start(pdev, 1); viafbinfo->fix.mmio_start = vdev->engine_start;
viafbinfo->fix.mmio_len = pci_resource_len(pdev, 1); viafbinfo->fix.mmio_len = vdev->engine_len;
viafbinfo->node = 0; viafbinfo->node = 0;
viafbinfo->fbops = &viafb_ops; viafbinfo->fbops = &viafb_ops;
viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
...@@ -1862,12 +1857,13 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev, ...@@ -1862,12 +1857,13 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev,
viafbinfo->var = default_var; viafbinfo->var = default_var;
if (viafb_dual_fb) { if (viafb_dual_fb) {
viafbinfo1 = framebuffer_alloc(viafb_par_length, &pdev->dev); viafbinfo1 = framebuffer_alloc(viafb_par_length,
&vdev->pdev->dev);
if (!viafbinfo1) { if (!viafbinfo1) {
printk(KERN_ERR printk(KERN_ERR
"allocate the second framebuffer struct error\n"); "allocate the second framebuffer struct error\n");
rc = -ENOMEM; rc = -ENOMEM;
goto out_unmap_screen; goto out_fb_release;
} }
viaparinfo1 = viafbinfo1->par; viaparinfo1 = viafbinfo1->par;
memcpy(viaparinfo1, viaparinfo, viafb_par_length); memcpy(viaparinfo1, viaparinfo, viafb_par_length);
...@@ -1958,8 +1954,6 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev, ...@@ -1958,8 +1954,6 @@ int __devinit via_fb_pci_probe(struct pci_dev *pdev,
out_fb1_release: out_fb1_release:
if (viafbinfo1) if (viafbinfo1)
framebuffer_release(viafbinfo1); framebuffer_release(viafbinfo1);
out_unmap_screen:
iounmap(viafbinfo->screen_base);
out_fb_release: out_fb_release:
framebuffer_release(viafbinfo); framebuffer_release(viafbinfo);
return rc; return rc;
...@@ -1972,8 +1966,6 @@ void __devexit via_fb_pci_remove(struct pci_dev *pdev) ...@@ -1972,8 +1966,6 @@ void __devexit via_fb_pci_remove(struct pci_dev *pdev)
unregister_framebuffer(viafbinfo); unregister_framebuffer(viafbinfo);
if (viafb_dual_fb) if (viafb_dual_fb)
unregister_framebuffer(viafbinfo1); unregister_framebuffer(viafbinfo1);
iounmap((void *)viafbinfo->screen_base);
iounmap(viaparinfo->shared->engine_mmio);
framebuffer_release(viafbinfo); framebuffer_release(viafbinfo);
if (viafb_dual_fb) if (viafb_dual_fb)
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "share.h" #include "share.h"
#include "chip.h" #include "chip.h"
#include "hw.h" #include "hw.h"
#include "via_i2c.h"
#define VERSION_MAJOR 2 #define VERSION_MAJOR 2
#define VERSION_KERNEL 6 /* For kernel 2.6 */ #define VERSION_KERNEL 6 /* For kernel 2.6 */
...@@ -42,6 +41,7 @@ ...@@ -42,6 +41,7 @@
struct viafb_shared { struct viafb_shared {
struct proc_dir_entry *proc_entry; /*viafb proc entry */ struct proc_dir_entry *proc_entry; /*viafb proc entry */
struct viafb_dev *vdev; /* Global dev info */
/* All the information will be needed to set engine */ /* All the information will be needed to set engine */
struct tmds_setting_information tmds_setting_info; struct tmds_setting_information tmds_setting_info;
...@@ -51,7 +51,6 @@ struct viafb_shared { ...@@ -51,7 +51,6 @@ struct viafb_shared {
struct chip_information chip_info; struct chip_information chip_info;
/* hardware acceleration stuff */ /* hardware acceleration stuff */
void __iomem *engine_mmio;
u32 cursor_vram_addr; u32 cursor_vram_addr;
u32 vq_vram_addr; /* virtual queue address in video ram */ u32 vq_vram_addr; /* virtual queue address in video ram */
int (*hw_bitblt)(void __iomem *engine, u8 op, u32 width, u32 height, int (*hw_bitblt)(void __iomem *engine, u8 op, u32 width, u32 height,
...@@ -72,14 +71,6 @@ struct viafb_par { ...@@ -72,14 +71,6 @@ struct viafb_par {
struct viafb_shared *shared; struct viafb_shared *shared;
/*
* (jc) I believe one should use locking to protect against
* concurrent access to the device ports and registers. Thus,
* this lock. Use of it is *far* from universal, though...
* someday...
*/
spinlock_t reg_lock;
/* All the information will be needed to set engine */ /* All the information will be needed to set engine */
/* depreciated, use the ones in shared directly */ /* depreciated, use the ones in shared directly */
struct tmds_setting_information *tmds_setting_info; struct tmds_setting_information *tmds_setting_info;
...@@ -107,7 +98,7 @@ u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information ...@@ -107,7 +98,7 @@ u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information
void viafb_gpio_i2c_write_mask_lvds(struct lvds_setting_information void viafb_gpio_i2c_write_mask_lvds(struct lvds_setting_information
*plvds_setting_info, struct lvds_chip_information *plvds_setting_info, struct lvds_chip_information
*plvds_chip_info, struct IODATA io_data); *plvds_chip_info, struct IODATA io_data);
int via_fb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent); int via_fb_pci_probe(struct viafb_dev *vdev);
void via_fb_pci_remove(struct pci_dev *pdev); void via_fb_pci_remove(struct pci_dev *pdev);
/* Temporary */ /* Temporary */
int viafb_init(void); int viafb_init(void);
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "via-core.h"
#include "via_i2c.h"
#include "global.h" #include "global.h"
u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment