diff options
Diffstat (limited to 'drivers/video/via')
31 files changed, 0 insertions, 13602 deletions
diff --git a/drivers/video/via/Makefile b/drivers/video/via/Makefile deleted file mode 100644 index 96f01ee2a41..00000000000 --- a/drivers/video/via/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# -# Makefile for the VIA framebuffer driver (for Linux Kernel 2.6) -# - -obj-$(CONFIG_FB_VIA) += viafb.o - -viafb-y :=viafbdev.o hw.o via_i2c.o dvi.o lcd.o ioctl.o accel.o \ - via_utility.o vt1636.o global.o tblDPASetting.o viamode.o \ - via-core.o via-gpio.o via_modesetting.o diff --git a/drivers/video/via/accel.c b/drivers/video/via/accel.c deleted file mode 100644 index 4b67b8e6030..00000000000 --- a/drivers/video/via/accel.c +++ /dev/null @@ -1,547 +0,0 @@ -/* - * 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 <linux/via-core.h> -#include "global.h" - -/* - * Figure out an appropriate bytes-per-pixel setting. - */ -static int viafb_set_bpp(void __iomem *engine, u8 bpp) -{ - u32 gemode; - - /* Preserve the reserved bits */ - /* Lowest 2 bits to zero gives us no rotation */ - gemode = readl(engine + VIA_REG_GEMODE) & 0xfffffcfc; - switch (bpp) { - case 8: - gemode |= VIA_GEM_8bpp; - break; - case 16: - gemode |= VIA_GEM_16bpp; - break; - case 32: - gemode |= VIA_GEM_32bpp; - break; - default: - printk(KERN_WARNING "viafb_set_bpp: Unsupported bpp %d\n", bpp); - return -EINVAL; - } - writel(gemode, engine + VIA_REG_GEMODE); - return 0; -} - - -static int hw_bitblt_1(void __iomem *engine, u8 op, u32 width, u32 height, - u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y, - u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y, - u32 fg_color, u32 bg_color, u8 fill_rop) -{ - u32 ge_cmd = 0, tmp, i; - int ret; - - if (!op || op > 3) { - printk(KERN_WARNING "hw_bitblt_1: Invalid operation: %d\n", op); - return -EINVAL; - } - - if (op != VIA_BITBLT_FILL && !src_mem && src_addr == dst_addr) { - if (src_x < dst_x) { - ge_cmd |= 0x00008000; - src_x += width - 1; - dst_x += width - 1; - } - if (src_y < dst_y) { - ge_cmd |= 0x00004000; - src_y += height - 1; - dst_y += height - 1; - } - } - - if (op == VIA_BITBLT_FILL) { - switch (fill_rop) { - case 0x00: /* blackness */ - case 0x5A: /* pattern inversion */ - case 0xF0: /* pattern copy */ - case 0xFF: /* whiteness */ - break; - default: - printk(KERN_WARNING "hw_bitblt_1: Invalid fill rop: " - "%u\n", fill_rop); - return -EINVAL; - } - } - - ret = viafb_set_bpp(engine, dst_bpp); - if (ret) - return ret; - - if (op != VIA_BITBLT_FILL) { - if (src_x & (op == VIA_BITBLT_MONO ? 0xFFFF8000 : 0xFFFFF000) - || src_y & 0xFFFFF000) { - printk(KERN_WARNING "hw_bitblt_1: Unsupported source " - "x/y %d %d\n", src_x, src_y); - return -EINVAL; - } - tmp = src_x | (src_y << 16); - writel(tmp, engine + 0x08); - } - - if (dst_x & 0xFFFFF000 || dst_y & 0xFFFFF000) { - printk(KERN_WARNING "hw_bitblt_1: Unsupported destination x/y " - "%d %d\n", dst_x, dst_y); - return -EINVAL; - } - tmp = dst_x | (dst_y << 16); - writel(tmp, engine + 0x0C); - - if ((width - 1) & 0xFFFFF000 || (height - 1) & 0xFFFFF000) { - printk(KERN_WARNING "hw_bitblt_1: Unsupported width/height " - "%d %d\n", width, height); - return -EINVAL; - } - tmp = (width - 1) | ((height - 1) << 16); - writel(tmp, engine + 0x10); - - if (op != VIA_BITBLT_COLOR) - writel(fg_color, engine + 0x18); - - if (op == VIA_BITBLT_MONO) - writel(bg_color, engine + 0x1C); - - if (op != VIA_BITBLT_FILL) { - tmp = src_mem ? 0 : src_addr; - if (dst_addr & 0xE0000007) { - printk(KERN_WARNING "hw_bitblt_1: Unsupported source " - "address %X\n", tmp); - return -EINVAL; - } - tmp >>= 3; - writel(tmp, engine + 0x30); - } - - if (dst_addr & 0xE0000007) { - printk(KERN_WARNING "hw_bitblt_1: Unsupported destination " - "address %X\n", dst_addr); - return -EINVAL; - } - tmp = dst_addr >> 3; - writel(tmp, engine + 0x34); - - if (op == VIA_BITBLT_FILL) - tmp = 0; - else - tmp = src_pitch; - if (tmp & 0xFFFFC007 || dst_pitch & 0xFFFFC007) { - printk(KERN_WARNING "hw_bitblt_1: Unsupported pitch %X %X\n", - tmp, dst_pitch); - return -EINVAL; - } - tmp = VIA_PITCH_ENABLE | (tmp >> 3) | (dst_pitch << (16 - 3)); - writel(tmp, engine + 0x38); - - if (op == VIA_BITBLT_FILL) - ge_cmd |= fill_rop << 24 | 0x00002000 | 0x00000001; - else { - ge_cmd |= 0xCC000000; /* ROP=SRCCOPY */ - if (src_mem) - ge_cmd |= 0x00000040; - if (op == VIA_BITBLT_MONO) - ge_cmd |= 0x00000002 | 0x00000100 | 0x00020000; - else - ge_cmd |= 0x00000001; - } - writel(ge_cmd, engine); - - if (op == VIA_BITBLT_FILL || !src_mem) - return 0; - - tmp = (width * height * (op == VIA_BITBLT_MONO ? 1 : (dst_bpp >> 3)) + - 3) >> 2; - - for (i = 0; i < tmp; i++) - writel(src_mem[i], engine + VIA_MMIO_BLTBASE); - - return 0; -} - -static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height, - u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y, - u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y, - u32 fg_color, u32 bg_color, u8 fill_rop) -{ - u32 ge_cmd = 0, tmp, i; - int ret; - - if (!op || op > 3) { - printk(KERN_WARNING "hw_bitblt_2: Invalid operation: %d\n", op); - return -EINVAL; - } - - if (op != VIA_BITBLT_FILL && !src_mem && src_addr == dst_addr) { - if (src_x < dst_x) { - ge_cmd |= 0x00008000; - src_x += width - 1; - dst_x += width - 1; - } - if (src_y < dst_y) { - ge_cmd |= 0x00004000; - src_y += height - 1; - dst_y += height - 1; - } - } - - if (op == VIA_BITBLT_FILL) { - switch (fill_rop) { - case 0x00: /* blackness */ - case 0x5A: /* pattern inversion */ - case 0xF0: /* pattern copy */ - case 0xFF: /* whiteness */ - break; - default: - printk(KERN_WARNING "hw_bitblt_2: Invalid fill rop: " - "%u\n", fill_rop); - return -EINVAL; - } - } - - ret = viafb_set_bpp(engine, dst_bpp); - if (ret) - return ret; - - if (op == VIA_BITBLT_FILL) - tmp = 0; - else - tmp = src_pitch; - if (tmp & 0xFFFFC007 || dst_pitch & 0xFFFFC007) { - printk(KERN_WARNING "hw_bitblt_2: Unsupported pitch %X %X\n", - tmp, dst_pitch); - return -EINVAL; - } - tmp = (tmp >> 3) | (dst_pitch << (16 - 3)); - writel(tmp, engine + 0x08); - - if ((width - 1) & 0xFFFFF000 || (height - 1) & 0xFFFFF000) { - printk(KERN_WARNING "hw_bitblt_2: Unsupported width/height " - "%d %d\n", width, height); - return -EINVAL; - } - tmp = (width - 1) | ((height - 1) << 16); - writel(tmp, engine + 0x0C); - - if (dst_x & 0xFFFFF000 || dst_y & 0xFFFFF000) { - printk(KERN_WARNING "hw_bitblt_2: Unsupported destination x/y " - "%d %d\n", dst_x, dst_y); - return -EINVAL; - } - tmp = dst_x | (dst_y << 16); - writel(tmp, engine + 0x10); - - if (dst_addr & 0xE0000007) { - printk(KERN_WARNING "hw_bitblt_2: Unsupported destination " - "address %X\n", dst_addr); - return -EINVAL; - } - tmp = dst_addr >> 3; - writel(tmp, engine + 0x14); - - if (op != VIA_BITBLT_FILL) { - if (src_x & (op == VIA_BITBLT_MONO ? 0xFFFF8000 : 0xFFFFF000) - || src_y & 0xFFFFF000) { - printk(KERN_WARNING "hw_bitblt_2: Unsupported source " - "x/y %d %d\n", src_x, src_y); - return -EINVAL; - } - tmp = src_x | (src_y << 16); - writel(tmp, engine + 0x18); - - tmp = src_mem ? 0 : src_addr; - if (dst_addr & 0xE0000007) { - printk(KERN_WARNING "hw_bitblt_2: Unsupported source " - "address %X\n", tmp); - return -EINVAL; - } - tmp >>= 3; - writel(tmp, engine + 0x1C); - } - - if (op == VIA_BITBLT_FILL) { - writel(fg_color, engine + 0x58); - } else if (op == VIA_BITBLT_MONO) { - writel(fg_color, engine + 0x4C); - writel(bg_color, engine + 0x50); - } - - if (op == VIA_BITBLT_FILL) - ge_cmd |= fill_rop << 24 | 0x00002000 | 0x00000001; - else { - ge_cmd |= 0xCC000000; /* ROP=SRCCOPY */ - if (src_mem) - ge_cmd |= 0x00000040; - if (op == VIA_BITBLT_MONO) - ge_cmd |= 0x00000002 | 0x00000100 | 0x00020000; - else - ge_cmd |= 0x00000001; - } - writel(ge_cmd, engine); - - if (op == VIA_BITBLT_FILL || !src_mem) - return 0; - - tmp = (width * height * (op == VIA_BITBLT_MONO ? 1 : (dst_bpp >> 3)) + - 3) >> 2; - - for (i = 0; i < tmp; i++) - writel(src_mem[i], engine + VIA_MMIO_BLTBASE); - - return 0; -} - -int viafb_setup_engine(struct fb_info *info) -{ - struct viafb_par *viapar = info->par; - void __iomem *engine; - u32 chip_name = viapar->shared->chip_info.gfx_chip_name; - - engine = viapar->shared->vdev->engine_mmio; - if (!engine) { - printk(KERN_WARNING "viafb_init_accel: ioremap failed, " - "hardware acceleration disabled\n"); - return -ENOMEM; - } - - switch (chip_name) { - case UNICHROME_CLE266: - case UNICHROME_K400: - case UNICHROME_K800: - case UNICHROME_PM800: - case UNICHROME_CN700: - case UNICHROME_CX700: - case UNICHROME_CN750: - case UNICHROME_K8M890: - case UNICHROME_P4M890: - case UNICHROME_P4M900: - viapar->shared->hw_bitblt = hw_bitblt_1; - break; - case UNICHROME_VX800: - case UNICHROME_VX855: - case UNICHROME_VX900: - viapar->shared->hw_bitblt = hw_bitblt_2; - break; - default: - viapar->shared->hw_bitblt = NULL; - } - - viapar->fbmem_free -= CURSOR_SIZE; - viapar->shared->cursor_vram_addr = viapar->fbmem_free; - viapar->fbmem_used += CURSOR_SIZE; - - viapar->fbmem_free -= VQ_SIZE; - viapar->shared->vq_vram_addr = viapar->fbmem_free; - viapar->fbmem_used += VQ_SIZE; - -#if defined(CONFIG_VIDEO_VIA_CAMERA) || defined(CONFIG_VIDEO_VIA_CAMERA_MODULE) - /* - * Set aside a chunk of framebuffer memory for the camera - * driver. Someday this driver probably needs a proper allocator - * for fbmem; for now, we just have to do this before the - * framebuffer initializes itself. - * - * As for the size: the engine can handle three frames, - * 16 bits deep, up to VGA resolution. - */ - viapar->shared->vdev->camera_fbmem_size = 3*VGA_HEIGHT*VGA_WIDTH*2; - viapar->fbmem_free -= viapar->shared->vdev->camera_fbmem_size; - viapar->fbmem_used += viapar->shared->vdev->camera_fbmem_size; - viapar->shared->vdev->camera_fbmem_offset = viapar->fbmem_free; -#endif - - viafb_reset_engine(viapar); - return 0; -} - -void viafb_reset_engine(struct viafb_par *viapar) -{ - void __iomem *engine = viapar->shared->vdev->engine_mmio; - int highest_reg, i; - 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; - - /* Initialize registers to reset the 2D engine */ - switch (viapar->shared->chip_info.twod_engine) { - case VIA_2D_ENG_M1: - highest_reg = 0x5c; - break; - default: - highest_reg = 0x40; - break; - } - for (i = 0; i <= highest_reg; i += 4) - writel(0x0, engine + i); - - /* Init AGP and VQ regs */ - switch (chip_name) { - case UNICHROME_K8M890: - case UNICHROME_P4M900: - case UNICHROME_VX800: - case UNICHROME_VX855: - case UNICHROME_VX900: - writel(0x00100000, engine + VIA_REG_CR_TRANSET); - writel(0x680A0000, engine + VIA_REG_CR_TRANSPACE); - writel(0x02000000, engine + VIA_REG_CR_TRANSPACE); - break; - - default: - writel(0x00100000, engine + VIA_REG_TRANSET); - writel(0x00000000, engine + VIA_REG_TRANSPACE); - writel(0x00333004, engine + VIA_REG_TRANSPACE); - writel(0x60000000, engine + VIA_REG_TRANSPACE); - writel(0x61000000, engine + VIA_REG_TRANSPACE); - writel(0x62000000, engine + VIA_REG_TRANSPACE); - writel(0x63000000, engine + VIA_REG_TRANSPACE); - writel(0x64000000, engine + VIA_REG_TRANSPACE); - writel(0x7D000000, engine + VIA_REG_TRANSPACE); - - writel(0xFE020000, engine + VIA_REG_TRANSET); - writel(0x00000000, engine + VIA_REG_TRANSPACE); - break; - } - - /* Enable VQ */ - vq_start_addr = viapar->shared->vq_vram_addr; - vq_end_addr = viapar->shared->vq_vram_addr + VQ_SIZE - 1; - - vq_start_low = 0x50000000 | (vq_start_addr & 0xFFFFFF); - vq_end_low = 0x51000000 | (vq_end_addr & 0xFFFFFF); - vq_high = 0x52000000 | ((vq_start_addr & 0xFF000000) >> 24) | - ((vq_end_addr & 0xFF000000) >> 16); - vq_len = 0x53000000 | (VQ_SIZE >> 3); - - switch (chip_name) { - case UNICHROME_K8M890: - case UNICHROME_P4M900: - case UNICHROME_VX800: - case UNICHROME_VX855: - case UNICHROME_VX900: - vq_start_low |= 0x20000000; - vq_end_low |= 0x20000000; - vq_high |= 0x20000000; - vq_len |= 0x20000000; - - writel(0x00100000, engine + VIA_REG_CR_TRANSET); - writel(vq_high, engine + VIA_REG_CR_TRANSPACE); - writel(vq_start_low, engine + VIA_REG_CR_TRANSPACE); - writel(vq_end_low, engine + VIA_REG_CR_TRANSPACE); - writel(vq_len, engine + VIA_REG_CR_TRANSPACE); - writel(0x74301001, engine + VIA_REG_CR_TRANSPACE); - writel(0x00000000, engine + VIA_REG_CR_TRANSPACE); - break; - default: - writel(0x00FE0000, engine + VIA_REG_TRANSET); - writel(0x080003FE, engine + VIA_REG_TRANSPACE); - writel(0x0A00027C, engine + VIA_REG_TRANSPACE); - writel(0x0B000260, engine + VIA_REG_TRANSPACE); - writel(0x0C000274, engine + VIA_REG_TRANSPACE); - writel(0x0D000264, engine + VIA_REG_TRANSPACE); - writel(0x0E000000, engine + VIA_REG_TRANSPACE); - writel(0x0F000020, engine + VIA_REG_TRANSPACE); - writel(0x1000027E, engine + VIA_REG_TRANSPACE); - writel(0x110002FE, engine + VIA_REG_TRANSPACE); - writel(0x200F0060, engine + VIA_REG_TRANSPACE); - - writel(0x00000006, engine + VIA_REG_TRANSPACE); - writel(0x40008C0F, engine + VIA_REG_TRANSPACE); - writel(0x44000000, engine + VIA_REG_TRANSPACE); - writel(0x45080C04, engine + VIA_REG_TRANSPACE); - writel(0x46800408, engine + VIA_REG_TRANSPACE); - - writel(vq_high, engine + VIA_REG_TRANSPACE); - writel(vq_start_low, engine + VIA_REG_TRANSPACE); - writel(vq_end_low, engine + VIA_REG_TRANSPACE); - writel(vq_len, engine + VIA_REG_TRANSPACE); - break; - } - - /* Set Cursor Image Base Address */ - writel(viapar->shared->cursor_vram_addr, engine + VIA_REG_CURSOR_MODE); - writel(0x0, engine + VIA_REG_CURSOR_POS); - writel(0x0, engine + VIA_REG_CURSOR_ORG); - writel(0x0, engine + VIA_REG_CURSOR_BG); - writel(0x0, engine + VIA_REG_CURSOR_FG); - return; -} - -void viafb_show_hw_cursor(struct fb_info *info, int Status) -{ - struct viafb_par *viapar = info->par; - u32 temp, iga_path = viapar->iga_path; - - temp = readl(viapar->shared->vdev->engine_mmio + VIA_REG_CURSOR_MODE); - switch (Status) { - case HW_Cursor_ON: - temp |= 0x1; - break; - case HW_Cursor_OFF: - temp &= 0xFFFFFFFE; - break; - } - switch (iga_path) { - case IGA2: - temp |= 0x80000000; - break; - case IGA1: - default: - temp &= 0x7FFFFFFF; - } - writel(temp, viapar->shared->vdev->engine_mmio + VIA_REG_CURSOR_MODE); -} - -void viafb_wait_engine_idle(struct fb_info *info) -{ - struct viafb_par *viapar = info->par; - int loop = 0; - u32 mask; - void __iomem *engine = viapar->shared->vdev->engine_mmio; - - switch (viapar->shared->chip_info.twod_engine) { - case VIA_2D_ENG_H5: - case VIA_2D_ENG_M1: - mask = VIA_CMD_RGTR_BUSY_M1 | VIA_2D_ENG_BUSY_M1 | - VIA_3D_ENG_BUSY_M1; - break; - default: - while (!(readl(engine + VIA_REG_STATUS) & - VIA_VR_QUEUE_BUSY) && (loop < MAXLOOP)) { - loop++; - cpu_relax(); - } - mask = VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY; - break; - } - - while ((readl(engine + VIA_REG_STATUS) & mask) && (loop < MAXLOOP)) { - loop++; - cpu_relax(); - } - - if (loop >= MAXLOOP) - printk(KERN_ERR "viafb_wait_engine_idle: not syncing\n"); -} diff --git a/drivers/video/via/accel.h b/drivers/video/via/accel.h deleted file mode 100644 index 79d5e10cc83..00000000000 --- a/drivers/video/via/accel.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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 __ACCEL_H__ -#define __ACCEL_H__ - -#define FB_ACCEL_VIA_UNICHROME 50 - -/* MMIO Base Address Definition */ -#define MMIO_VGABASE 0x8000 -#define MMIO_CR_READ (MMIO_VGABASE + 0x3D4) -#define MMIO_CR_WRITE (MMIO_VGABASE + 0x3D5) -#define MMIO_SR_READ (MMIO_VGABASE + 0x3C4) -#define MMIO_SR_WRITE (MMIO_VGABASE + 0x3C5) - -/* HW Cursor Status Define */ -#define HW_Cursor_ON 0 -#define HW_Cursor_OFF 1 - -#define CURSOR_SIZE (8 * 1024) -#define VQ_SIZE (256 * 1024) - -#define VIA_MMIO_BLTBASE 0x200000 -#define VIA_MMIO_BLTSIZE 0x200000 - -/* Defines for 2D registers */ -#define VIA_REG_GECMD 0x000 -#define VIA_REG_GEMODE 0x004 -#define VIA_REG_SRCPOS 0x008 -#define VIA_REG_DSTPOS 0x00C -/* width and height */ -#define VIA_REG_DIMENSION 0x010 -#define VIA_REG_PATADDR 0x014 -#define VIA_REG_FGCOLOR 0x018 -#define VIA_REG_BGCOLOR 0x01C -/* top and left of clipping */ -#define VIA_REG_CLIPTL 0x020 -/* bottom and right of clipping */ -#define VIA_REG_CLIPBR 0x024 -#define VIA_REG_OFFSET 0x028 -/* color key control */ -#define VIA_REG_KEYCONTROL 0x02C -#define VIA_REG_SRCBASE 0x030 -#define VIA_REG_DSTBASE 0x034 -/* pitch of src and dst */ -#define VIA_REG_PITCH 0x038 -#define VIA_REG_MONOPAT0 0x03C -#define VIA_REG_MONOPAT1 0x040 -/* from 0x100 to 0x1ff */ -#define VIA_REG_COLORPAT 0x100 - -/* defines for VIA 2D registers for vt3353/3409 (M1 engine)*/ -#define VIA_REG_GECMD_M1 0x000 -#define VIA_REG_GEMODE_M1 0x004 -#define VIA_REG_GESTATUS_M1 0x004 /* as same as VIA_REG_GEMODE */ -#define VIA_REG_PITCH_M1 0x008 /* pitch of src and dst */ -#define VIA_REG_DIMENSION_M1 0x00C /* width and height */ -#define VIA_REG_DSTPOS_M1 0x010 -#define VIA_REG_LINE_XY_M1 0x010 -#define VIA_REG_DSTBASE_M1 0x014 -#define VIA_REG_SRCPOS_M1 0x018 -#define VIA_REG_LINE_K1K2_M1 0x018 -#define VIA_REG_SRCBASE_M1 0x01C -#define VIA_REG_PATADDR_M1 0x020 -#define VIA_REG_MONOPAT0_M1 0x024 -#define VIA_REG_MONOPAT1_M1 0x028 -#define VIA_REG_OFFSET_M1 0x02C -#define VIA_REG_LINE_ERROR_M1 0x02C -#define VIA_REG_CLIPTL_M1 0x040 /* top and left of clipping */ -#define VIA_REG_CLIPBR_M1 0x044 /* bottom and right of clipping */ -#define VIA_REG_KEYCONTROL_M1 0x048 /* color key control */ -#define VIA_REG_FGCOLOR_M1 0x04C -#define VIA_REG_DSTCOLORKEY_M1 0x04C /* as same as VIA_REG_FG */ -#define VIA_REG_BGCOLOR_M1 0x050 -#define VIA_REG_SRCCOLORKEY_M1 0x050 /* as same as VIA_REG_BG */ -#define VIA_REG_MONOPATFGC_M1 0x058 /* Add BG color of Pattern. */ -#define VIA_REG_MONOPATBGC_M1 0x05C /* Add FG color of Pattern. */ -#define VIA_REG_COLORPAT_M1 0x100 /* from 0x100 to 0x1ff */ - -/* VIA_REG_PITCH(0x38): Pitch Setting */ -#define VIA_PITCH_ENABLE 0x80000000 - -/* defines for VIA HW cursor registers */ -#define VIA_REG_CURSOR_MODE 0x2D0 -#define VIA_REG_CURSOR_POS 0x2D4 -#define VIA_REG_CURSOR_ORG 0x2D8 -#define VIA_REG_CURSOR_BG 0x2DC -#define VIA_REG_CURSOR_FG 0x2E0 - -/* VIA_REG_GEMODE(0x04): GE mode */ -#define VIA_GEM_8bpp 0x00000000 -#define VIA_GEM_16bpp 0x00000100 -#define VIA_GEM_32bpp 0x00000300 - -/* VIA_REG_GECMD(0x00): 2D Engine Command */ -#define VIA_GEC_NOOP 0x00000000 -#define VIA_GEC_BLT 0x00000001 -#define VIA_GEC_LINE 0x00000005 - -/* Rotate Command */ -#define VIA_GEC_ROT 0x00000008 - -#define VIA_GEC_SRC_XY 0x00000000 -#define VIA_GEC_SRC_LINEAR 0x00000010 -#define VIA_GEC_DST_XY 0x00000000 -#define VIA_GEC_DST_LINRAT 0x00000020 - -#define VIA_GEC_SRC_FB 0x00000000 -#define VIA_GEC_SRC_SYS 0x00000040 -#define VIA_GEC_DST_FB 0x00000000 -#define VIA_GEC_DST_SYS 0x00000080 - -/* source is mono */ -#define VIA_GEC_SRC_MONO 0x00000100 -/* pattern is mono */ -#define VIA_GEC_PAT_MONO 0x00000200 -/* mono src is opaque */ -#define VIA_GEC_MSRC_OPAQUE 0x00000000 -/* mono src is transparent */ -#define VIA_GEC_MSRC_TRANS 0x00000400 -/* pattern is in frame buffer */ -#define VIA_GEC_PAT_FB 0x00000000 -/* pattern is from reg setting */ -#define VIA_GEC_PAT_REG 0x00000800 - -#define VIA_GEC_CLIP_DISABLE 0x00000000 -#define VIA_GEC_CLIP_ENABLE 0x00001000 - -#define VIA_GEC_FIXCOLOR_PAT 0x00002000 - -#define VIA_GEC_INCX 0x00000000 -#define VIA_GEC_DECY 0x00004000 -#define VIA_GEC_INCY 0x00000000 -#define VIA_GEC_DECX 0x00008000 -/* mono pattern is opaque */ -#define VIA_GEC_MPAT_OPAQUE 0x00000000 -/* mono pattern is transparent */ -#define VIA_GEC_MPAT_TRANS 0x00010000 - -#define VIA_GEC_MONO_UNPACK 0x00000000 -#define VIA_GEC_MONO_PACK 0x00020000 -#define VIA_GEC_MONO_DWORD 0x00000000 -#define VIA_GEC_MONO_WORD 0x00040000 -#define VIA_GEC_MONO_BYTE 0x00080000 - -#define VIA_GEC_LASTPIXEL_ON 0x00000000 -#define VIA_GEC_LASTPIXEL_OFF 0x00100000 -#define VIA_GEC_X_MAJOR 0x00000000 -#define VIA_GEC_Y_MAJOR 0x00200000 -#define VIA_GEC_QUICK_START 0x00800000 - -/* defines for VIA 3D registers */ -#define VIA_REG_STATUS 0x400 -#define VIA_REG_CR_TRANSET 0x41C -#define VIA_REG_CR_TRANSPACE 0x420 -#define VIA_REG_TRANSET 0x43C -#define VIA_REG_TRANSPACE 0x440 - -/* VIA_REG_STATUS(0x400): Engine Status */ - -/* Command Regulator is busy */ -#define VIA_CMD_RGTR_BUSY 0x00000080 -/* 2D Engine is busy */ -#define VIA_2D_ENG_BUSY 0x00000002 -/* 3D Engine is busy */ -#define VIA_3D_ENG_BUSY 0x00000001 -/* Virtual Queue is busy */ -#define VIA_VR_QUEUE_BUSY 0x00020000 - -/* VIA_REG_STATUS(0x400): Engine Status for H5 */ -#define VIA_CMD_RGTR_BUSY_H5 0x00000010 /* Command Regulator is busy */ -#define VIA_2D_ENG_BUSY_H5 0x00000002 /* 2D Engine is busy */ -#define VIA_3D_ENG_BUSY_H5 0x00001FE1 /* 3D Engine is busy */ -#define VIA_VR_QUEUE_BUSY_H5 0x00000004 /* Virtual Queue is busy */ - -/* VIA_REG_STATUS(0x400): Engine Status for VT3353/3409 */ -#define VIA_CMD_RGTR_BUSY_M1 0x00000010 /* Command Regulator is busy */ -#define VIA_2D_ENG_BUSY_M1 0x00000002 /* 2D Engine is busy */ -#define VIA_3D_ENG_BUSY_M1 0x00001FE1 /* 3D Engine is busy */ -#define VIA_VR_QUEUE_BUSY_M1 0x00000004 /* Virtual Queue is busy */ - -#define MAXLOOP 0xFFFFFF - -#define VIA_BITBLT_COLOR 1 -#define VIA_BITBLT_MONO 2 -#define VIA_BITBLT_FILL 3 - -int viafb_setup_engine(struct fb_info *info); -void viafb_reset_engine(struct viafb_par *viapar); -void viafb_show_hw_cursor(struct fb_info *info, int Status); -void viafb_wait_engine_idle(struct fb_info *info); - -#endif /* __ACCEL_H__ */ diff --git a/drivers/video/via/chip.h b/drivers/video/via/chip.h deleted file mode 100644 index 48f1342897b..00000000000 --- a/drivers/video/via/chip.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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 __CHIP_H__ -#define __CHIP_H__ - -#include "global.h" - -/***************************************/ -/* Definition Graphic Chip Information */ -/***************************************/ - -#define PCI_VIA_VENDOR_ID 0x1106 - -/* Define VIA Graphic Chip Name */ -#define UNICHROME_CLE266 1 -#define UNICHROME_CLE266_DID 0x3122 -#define CLE266_REVISION_AX 0x0A -#define CLE266_REVISION_CX 0x0C - -#define UNICHROME_K400 2 -#define UNICHROME_K400_DID 0x7205 - -#define UNICHROME_K800 3 -#define UNICHROME_K800_DID 0x3108 - -#define UNICHROME_PM800 4 -#define UNICHROME_PM800_DID 0x3118 - -#define UNICHROME_CN700 5 -#define UNICHROME_CN700_DID 0x3344 - -#define UNICHROME_CX700 6 -#define UNICHROME_CX700_DID 0x3157 -#define CX700_REVISION_700 0x0 -#define CX700_REVISION_700M 0x1 -#define CX700_REVISION_700M2 0x2 - -#define UNICHROME_CN750 7 -#define UNICHROME_CN750_DID 0x3225 - -#define UNICHROME_K8M890 8 -#define UNICHROME_K8M890_DID 0x3230 - -#define UNICHROME_P4M890 9 -#define UNICHROME_P4M890_DID 0x3343 - -#define UNICHROME_P4M900 10 -#define UNICHROME_P4M900_DID 0x3371 - -#define UNICHROME_VX800 11 -#define UNICHROME_VX800_DID 0x1122 - -#define UNICHROME_VX855 12 -#define UNICHROME_VX855_DID 0x5122 - -#define UNICHROME_VX900 13 -#define UNICHROME_VX900_DID 0x7122 - -/**************************************************/ -/* Definition TMDS Trasmitter Information */ -/**************************************************/ - -/* Definition TMDS Trasmitter Index */ -#define NON_TMDS_TRANSMITTER 0x00 -#define VT1632_TMDS 0x01 -#define INTEGRATED_TMDS 0x42 - -/* Definition TMDS Trasmitter I2C Slave Address */ -#define VT1632_TMDS_I2C_ADDR 0x10 - -/**************************************************/ -/* Definition LVDS Trasmitter Information */ -/**************************************************/ - -/* Definition LVDS Trasmitter Index */ -#define NON_LVDS_TRANSMITTER 0x00 -#define VT1631_LVDS 0x01 -#define VT1636_LVDS 0x0E -#define INTEGRATED_LVDS 0x41 - -/* Definition Digital Transmitter Mode */ -#define TX_DATA_12_BITS 0x01 -#define TX_DATA_24_BITS 0x02 -#define TX_DATA_DDR_MODE 0x04 -#define TX_DATA_SDR_MODE 0x08 - -/* Definition LVDS Trasmitter I2C Slave Address */ -#define VT1631_LVDS_I2C_ADDR 0x70 -#define VT3271_LVDS_I2C_ADDR 0x80 -#define VT1636_LVDS_I2C_ADDR 0x80 - -struct tmds_chip_information { - int tmds_chip_name; - int tmds_chip_slave_addr; - int data_mode; - int output_interface; - int i2c_port; - int device_type; -}; - -struct lvds_chip_information { - int lvds_chip_name; - int lvds_chip_slave_addr; - int data_mode; - int output_interface; - int i2c_port; -}; - -/* The type of 2D engine */ -enum via_2d_engine { - VIA_2D_ENG_H2, - VIA_2D_ENG_H5, - VIA_2D_ENG_M1, -}; - -struct chip_information { - int gfx_chip_name; - int gfx_chip_revision; - enum via_2d_engine twod_engine; - struct tmds_chip_information tmds_chip_info; - struct lvds_chip_information lvds_chip_info; - struct lvds_chip_information lvds_chip_info2; -}; - -struct crt_setting_information { - int iga_path; - int h_active; - int v_active; - int bpp; - int refresh_rate; -}; - -struct tmds_setting_information { - int iga_path; - int h_active; - int v_active; - int max_pixel_clock; - int max_hres; - int max_vres; -}; - -struct lvds_setting_information { - int iga_path; - int h_active; - int v_active; - int bpp; - int refresh_rate; - int lcd_panel_id; - int lcd_panel_hres; - int lcd_panel_vres; - int display_method; - int device_lcd_dualedge; - int LCDDithering; - int lcd_mode; - u32 vclk; /*panel mode clock value */ -}; - -struct GFX_DPA_SETTING { - int ClkRangeIndex; - u8 DVP0; /* CR96[3:0] */ - u8 DVP0DataDri_S1; /* SR2A[5] */ - u8 DVP0DataDri_S; /* SR1B[1] */ - u8 DVP0ClockDri_S1; /* SR2A[4] */ - u8 DVP0ClockDri_S; /* SR1E[2] */ - u8 DVP1; /* CR9B[3:0] */ - u8 DVP1Driving; /* SR65[3:0], Data and Clock driving */ - u8 DFPHigh; /* CR97[3:0] */ - u8 DFPLow; /* CR99[3:0] */ - -}; - -struct VT1636_DPA_SETTING { - int PanelSizeID; - u8 CLK_SEL_ST1; - u8 CLK_SEL_ST2; -}; -#endif /* __CHIP_H__ */ diff --git a/drivers/video/via/debug.h b/drivers/video/via/debug.h deleted file mode 100644 index 86eacc2017f..00000000000 --- a/drivers/video/via/debug.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 __DEBUG_H__ -#define __DEBUG_H__ - -#ifndef VIAFB_DEBUG -#define VIAFB_DEBUG 0 -#endif - -#if VIAFB_DEBUG -#define DEBUG_MSG(f, a...) printk(f, ## a) -#else -#define DEBUG_MSG(f, a...) -#endif - -#define VIAFB_WARN 0 -#if VIAFB_WARN -#define WARN_MSG(f, a...) printk(f, ## a) -#else -#define WARN_MSG(f, a...) -#endif - -#endif /* __DEBUG_H__ */ diff --git a/drivers/video/via/dvi.c b/drivers/video/via/dvi.c deleted file mode 100644 index 84e21b39dd0..00000000000 --- a/drivers/video/via/dvi.c +++ /dev/null @@ -1,621 +0,0 @@ -/* - * 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 <linux/via-core.h> -#include <linux/via_i2c.h> -#include "global.h" - -static void tmds_register_write(int index, u8 data); -static int tmds_register_read(int index); -static int tmds_register_read_bytes(int index, u8 *buff, int buff_len); -static void __devinit dvi_get_panel_size_from_DDCv1( - struct tmds_chip_information *tmds_chip, - struct tmds_setting_information *tmds_setting); -static void __devinit dvi_get_panel_size_from_DDCv2( - struct tmds_chip_information *tmds_chip, - struct tmds_setting_information *tmds_setting); -static int viafb_dvi_query_EDID(void); - -static int check_tmds_chip(int device_id_subaddr, int device_id) -{ - if (tmds_register_read(device_id_subaddr) == device_id) - return OK; - else - return FAIL; -} - -void __devinit viafb_init_dvi_size(struct tmds_chip_information *tmds_chip, - struct tmds_setting_information *tmds_setting) -{ - DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n"); - - viafb_dvi_sense(); - switch (viafb_dvi_query_EDID()) { - case 1: - dvi_get_panel_size_from_DDCv1(tmds_chip, tmds_setting); - break; - case 2: - dvi_get_panel_size_from_DDCv2(tmds_chip, tmds_setting); - break; - default: - printk(KERN_WARNING "viafb_init_dvi_size: DVI panel size undetected!\n"); - break; - } - - return; -} - -int __devinit viafb_tmds_trasmitter_identify(void) -{ - unsigned char sr2a = 0, sr1e = 0, sr3e = 0; - - /* Turn on ouputting pad */ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_K8M890: - /*=* DFP Low Pad on *=*/ - sr2a = viafb_read_reg(VIASR, SR2A); - viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1); - break; - - case UNICHROME_P4M900: - case UNICHROME_P4M890: - /* DFP Low Pad on */ - sr2a = viafb_read_reg(VIASR, SR2A); - viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1); - /* DVP0 Pad on */ - sr1e = viafb_read_reg(VIASR, SR1E); - viafb_write_reg_mask(SR1E, VIASR, 0xC0, BIT6 + BIT7); - break; - - default: - /* DVP0/DVP1 Pad on */ - sr1e = viafb_read_reg(VIASR, SR1E); - viafb_write_reg_mask(SR1E, VIASR, 0xF0, BIT4 + - BIT5 + BIT6 + BIT7); - /* SR3E[1]Multi-function selection: - 0 = Emulate I2C and DDC bus by GPIO2/3/4. */ - sr3e = viafb_read_reg(VIASR, SR3E); - viafb_write_reg_mask(SR3E, VIASR, 0x0, BIT5); - break; - } - - /* Check for VT1632: */ - viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = VT1632_TMDS; - viaparinfo->chip_info-> - tmds_chip_info.tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR; - viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_PORT_31; - if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) != FAIL) { - /* - * Currently only support 12bits,dual edge,add 24bits mode later - */ - tmds_register_write(0x08, 0x3b); - - DEBUG_MSG(KERN_INFO "\n VT1632 TMDS ! \n"); - DEBUG_MSG(KERN_INFO "\n %2d", - viaparinfo->chip_info->tmds_chip_info.tmds_chip_name); - DEBUG_MSG(KERN_INFO "\n %2d", - viaparinfo->chip_info->tmds_chip_info.i2c_port); - return OK; - } else { - viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_PORT_2C; - if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) - != FAIL) { - tmds_register_write(0x08, 0x3b); - DEBUG_MSG(KERN_INFO "\n VT1632 TMDS ! \n"); - DEBUG_MSG(KERN_INFO "\n %2d", - viaparinfo->chip_info-> - tmds_chip_info.tmds_chip_name); - DEBUG_MSG(KERN_INFO "\n %2d", - viaparinfo->chip_info-> - tmds_chip_info.i2c_port); - return OK; - } - } - - viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = INTEGRATED_TMDS; - - if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) && - ((viafb_display_hardware_layout == HW_LAYOUT_DVI_ONLY) || - (viafb_display_hardware_layout == HW_LAYOUT_LCD_DVI))) { - DEBUG_MSG(KERN_INFO "\n Integrated TMDS ! \n"); - return OK; - } - - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_K8M890: - viafb_write_reg(SR2A, VIASR, sr2a); - break; - - case UNICHROME_P4M900: - case UNICHROME_P4M890: - viafb_write_reg(SR2A, VIASR, sr2a); - viafb_write_reg(SR1E, VIASR, sr1e); - break; - - default: - viafb_write_reg(SR1E, VIASR, sr1e); - viafb_write_reg(SR3E, VIASR, sr3e); - break; - } - - viaparinfo->chip_info-> - tmds_chip_info.tmds_chip_name = NON_TMDS_TRANSMITTER; - viaparinfo->chip_info->tmds_chip_info. - tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR; - return FAIL; -} - -static void tmds_register_write(int index, u8 data) -{ - viafb_i2c_writebyte(viaparinfo->chip_info->tmds_chip_info.i2c_port, - viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr, - index, data); -} - -static int tmds_register_read(int index) -{ - u8 data; - - viafb_i2c_readbyte(viaparinfo->chip_info->tmds_chip_info.i2c_port, - (u8) viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr, - (u8) index, &data); - return data; -} - -static int tmds_register_read_bytes(int index, u8 *buff, int buff_len) -{ - viafb_i2c_readbytes(viaparinfo->chip_info->tmds_chip_info.i2c_port, - (u8) viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr, - (u8) index, buff, buff_len); - return 0; -} - -/* DVI Set Mode */ -void viafb_dvi_set_mode(struct VideoModeTable *mode, int mode_bpp, - int set_iga) -{ - struct VideoModeTable *rb_mode; - struct crt_mode_table *pDviTiming; - unsigned long desirePixelClock, maxPixelClock; - pDviTiming = mode->crtc; - desirePixelClock = pDviTiming->clk / 1000000; - maxPixelClock = (unsigned long)viaparinfo-> - tmds_setting_info->max_pixel_clock; - - DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n"); - - if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) { - rb_mode = viafb_get_rb_mode(mode->crtc[0].crtc.hor_addr, - mode->crtc[0].crtc.ver_addr); - if (rb_mode) { - mode = rb_mode; - pDviTiming = rb_mode->crtc; - } - } - viafb_fill_crtc_timing(pDviTiming, mode, mode_bpp / 8, set_iga); -} - -/* Sense DVI Connector */ -int viafb_dvi_sense(void) -{ - u8 RegSR1E = 0, RegSR3E = 0, RegCR6B = 0, RegCR91 = 0, - RegCR93 = 0, RegCR9B = 0, data; - int ret = false; - - DEBUG_MSG(KERN_INFO "viafb_dvi_sense!!\n"); - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { - /* DI1 Pad on */ - RegSR1E = viafb_read_reg(VIASR, SR1E); - viafb_write_reg(SR1E, VIASR, RegSR1E | 0x30); - - /* CR6B[0]VCK Input Selection: 1 = External clock. */ - RegCR6B = viafb_read_reg(VIACR, CR6B); - viafb_write_reg(CR6B, VIACR, RegCR6B | 0x08); - - /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off - [0] Software Control Power Sequence */ - RegCR91 = viafb_read_reg(VIACR, CR91); - viafb_write_reg(CR91, VIACR, 0x1D); - - /* CR93[7] DI1 Data Source Selection: 1 = DSP2. - CR93[5] DI1 Clock Source: 1 = internal. - CR93[4] DI1 Clock Polarity. - CR93[3:1] DI1 Clock Adjust. CR93[0] DI1 enable */ - RegCR93 = viafb_read_reg(VIACR, CR93); - viafb_write_reg(CR93, VIACR, 0x01); - } else { - /* DVP0/DVP1 Pad on */ - RegSR1E = viafb_read_reg(VIASR, SR1E); - viafb_write_reg(SR1E, VIASR, RegSR1E | 0xF0); - - /* SR3E[1]Multi-function selection: - 0 = Emulate I2C and DDC bus by GPIO2/3/4. */ - RegSR3E = viafb_read_reg(VIASR, SR3E); - viafb_write_reg(SR3E, VIASR, RegSR3E & (~0x20)); - - /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off - [0] Software Control Power Sequence */ - RegCR91 = viafb_read_reg(VIACR, CR91); - viafb_write_reg(CR91, VIACR, 0x1D); - - /*CR9B[4] DVP1 Data Source Selection: 1 = From secondary - display.CR9B[2:0] DVP1 Clock Adjust */ - RegCR9B = viafb_read_reg(VIACR, CR9B); - viafb_write_reg(CR9B, VIACR, 0x01); - } - - data = (u8) tmds_register_read(0x09); - if (data & 0x04) - ret = true; - - if (ret == false) { - if (viafb_dvi_query_EDID()) - ret = true; - } - - /* Restore status */ - viafb_write_reg(SR1E, VIASR, RegSR1E); - viafb_write_reg(CR91, VIACR, RegCR91); - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { - viafb_write_reg(CR6B, VIACR, RegCR6B); - viafb_write_reg(CR93, VIACR, RegCR93); - } else { - viafb_write_reg(SR3E, VIASR, RegSR3E); - viafb_write_reg(CR9B, VIACR, RegCR9B); - } - - return ret; -} - -/* Query Flat Panel's EDID Table Version Through DVI Connector */ -static int viafb_dvi_query_EDID(void) -{ - u8 data0, data1; - int restore; - - DEBUG_MSG(KERN_INFO "viafb_dvi_query_EDID!!\n"); - - restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr; - viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0; - - data0 = (u8) tmds_register_read(0x00); - data1 = (u8) tmds_register_read(0x01); - if ((data0 == 0) && (data1 == 0xFF)) { - viaparinfo->chip_info-> - tmds_chip_info.tmds_chip_slave_addr = restore; - return EDID_VERSION_1; /* Found EDID1 Table */ - } - - data0 = (u8) tmds_register_read(0x00); - viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore; - if (data0 == 0x20) - return EDID_VERSION_2; /* Found EDID2 Table */ - else - return false; -} - -/* Get Panel Size Using EDID1 Table */ -static void __devinit dvi_get_panel_size_from_DDCv1( - struct tmds_chip_information *tmds_chip, - struct tmds_setting_information *tmds_setting) -{ - int i, max_h = 0, tmp, restore; - unsigned char rData; - unsigned char EDID_DATA[18]; - - DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n"); - - restore = tmds_chip->tmds_chip_slave_addr; - tmds_chip->tmds_chip_slave_addr = 0xA0; - - rData = tmds_register_read(0x23); - if (rData & 0x3C) - max_h = 640; - if (rData & 0xC0) - max_h = 720; - if (rData & 0x03) - max_h = 800; - - rData = tmds_register_read(0x24); - if (rData & 0xC0) - max_h = 800; - if (rData & 0x1E) - max_h = 1024; - if (rData & 0x01) - max_h = 1280; - - for (i = 0x25; i < 0x6D; i++) { - switch (i) { - case 0x26: - case 0x28: - case 0x2A: - case 0x2C: - case 0x2E: - case 0x30: - case 0x32: - case 0x34: - rData = tmds_register_read(i); - if (rData == 1) - break; - /* data = (data + 31) * 8 */ - tmp = (rData + 31) << 3; - if (tmp > max_h) - max_h = tmp; - break; - - case 0x36: - case 0x48: - case 0x5A: - case 0x6C: - tmds_register_read_bytes(i, EDID_DATA, 10); - if (!(EDID_DATA[0] || EDID_DATA[1])) { - /* The first two byte must be zero. */ - if (EDID_DATA[3] == 0xFD) { - /* To get max pixel clock. */ - tmds_setting->max_pixel_clock = - EDID_DATA[9] * 10; - } - } - break; - - default: - break; - } - } - - tmds_setting->max_hres = max_h; - switch (max_h) { - case 640: - tmds_setting->max_vres = 480; - break; - case 800: - tmds_setting->max_vres = 600; - break; - case 1024: - tmds_setting->max_vres = 768; - break; - case 1280: - tmds_setting->max_vres = 1024; - break; - case 1400: - tmds_setting->max_vres = 1050; - break; - case 1440: - tmds_setting->max_vres = 1050; - break; - case 1600: - tmds_setting->max_vres = 1200; - break; - case 1920: - tmds_setting->max_vres = 1080; - break; - default: - DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d ! " - "set default panel size.\n", max_h); - break; - } - - DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n", - tmds_setting->max_pixel_clock); - tmds_chip->tmds_chip_slave_addr = restore; -} - -/* Get Panel Size Using EDID2 Table */ -static void __devinit dvi_get_panel_size_from_DDCv2( - struct tmds_chip_information *tmds_chip, - struct tmds_setting_information *tmds_setting) -{ - int restore; - unsigned char R_Buffer[2]; - - DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n"); - - restore = tmds_chip->tmds_chip_slave_addr; - tmds_chip->tmds_chip_slave_addr = 0xA2; - - /* Horizontal: 0x76, 0x77 */ - tmds_register_read_bytes(0x76, R_Buffer, 2); - tmds_setting->max_hres = R_Buffer[0] + (R_Buffer[1] << 8); - - switch (tmds_setting->max_hres) { - case 640: - tmds_setting->max_vres = 480; - break; - case 800: - tmds_setting->max_vres = 600; - break; - case 1024: - tmds_setting->max_vres = 768; - break; - case 1280: - tmds_setting->max_vres = 1024; - break; - case 1400: - tmds_setting->max_vres = 1050; - break; - case 1440: - tmds_setting->max_vres = 1050; - break; - case 1600: - tmds_setting->max_vres = 1200; - break; - default: - DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d! " - "set default panel size.\n", tmds_setting->max_hres); - break; - } - - tmds_chip->tmds_chip_slave_addr = restore; -} - -/* If Disable DVI, turn off pad */ -void viafb_dvi_disable(void) -{ - if (viaparinfo->chip_info-> - tmds_chip_info.output_interface == INTERFACE_TMDS) - /* Turn off TMDS power. */ - viafb_write_reg(CRD2, VIACR, - viafb_read_reg(VIACR, CRD2) | 0x08); -} - -static void dvi_patch_skew_dvp0(void) -{ - /* Reset data driving first: */ - viafb_write_reg_mask(SR1B, VIASR, 0, BIT1); - viafb_write_reg_mask(SR2A, VIASR, 0, BIT4); - - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_P4M890: - { - if ((viaparinfo->tmds_setting_info->h_active == 1600) && - (viaparinfo->tmds_setting_info->v_active == - 1200)) - viafb_write_reg_mask(CR96, VIACR, 0x03, - BIT0 + BIT1 + BIT2); - else - viafb_write_reg_mask(CR96, VIACR, 0x07, - BIT0 + BIT1 + BIT2); - break; - } - - case UNICHROME_P4M900: - { - viafb_write_reg_mask(CR96, VIACR, 0x07, - BIT0 + BIT1 + BIT2 + BIT3); - viafb_write_reg_mask(SR1B, VIASR, 0x02, BIT1); - viafb_write_reg_mask(SR2A, VIASR, 0x10, BIT4); - break; - } - - default: - { - break; - } - } -} - -static void dvi_patch_skew_dvp_low(void) -{ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_K8M890: - { - viafb_write_reg_mask(CR99, VIACR, 0x03, BIT0 + BIT1); - break; - } - - case UNICHROME_P4M900: - { - viafb_write_reg_mask(CR99, VIACR, 0x08, - BIT0 + BIT1 + BIT2 + BIT3); - break; - } - - case UNICHROME_P4M890: - { - viafb_write_reg_mask(CR99, VIACR, 0x0F, - BIT0 + BIT1 + BIT2 + BIT3); - break; - } - - default: - { - break; - } - } -} - -/* If Enable DVI, turn off pad */ -void viafb_dvi_enable(void) -{ - u8 data; - - switch (viaparinfo->chip_info->tmds_chip_info.output_interface) { - case INTERFACE_DVP0: - viafb_write_reg_mask(CR6B, VIACR, 0x01, BIT0); - viafb_write_reg_mask(CR6C, VIACR, 0x21, BIT0 + BIT5); - dvi_patch_skew_dvp0(); - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) - tmds_register_write(0x88, 0x3b); - else - /*clear CR91[5] to direct on display period - in the secondary diplay path */ - via_write_reg_mask(VIACR, 0x91, 0x00, 0x20); - break; - - case INTERFACE_DVP1: - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) - viafb_write_reg_mask(CR93, VIACR, 0x21, BIT0 + BIT5); - - /*fix dvi cann't be enabled with MB VT5718C4 - Al Zhang */ - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) - tmds_register_write(0x88, 0x3b); - else - /*clear CR91[5] to direct on display period - in the secondary diplay path */ - via_write_reg_mask(VIACR, 0x91, 0x00, 0x20); - - /*fix DVI cannot enable on EPIA-M board */ - if (viafb_platform_epia_dvi == 1) { - viafb_write_reg_mask(CR91, VIACR, 0x1f, 0x1f); - viafb_write_reg_mask(CR88, VIACR, 0x00, BIT6 + BIT0); - if (viafb_bus_width == 24) { - if (viafb_device_lcd_dualedge == 1) - data = 0x3F; - else - data = 0x37; - viafb_i2c_writebyte(viaparinfo->chip_info-> - tmds_chip_info.i2c_port, - viaparinfo->chip_info-> - tmds_chip_info.tmds_chip_slave_addr, - 0x08, data); - } - } - break; - - case INTERFACE_DFP_HIGH: - if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266) - via_write_reg_mask(VIACR, CR97, 0x03, 0x03); - - via_write_reg_mask(VIACR, 0x91, 0x00, 0x20); - break; - - case INTERFACE_DFP_LOW: - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) - break; - - dvi_patch_skew_dvp_low(); - via_write_reg_mask(VIACR, 0x91, 0x00, 0x20); - break; - - case INTERFACE_TMDS: - /* Turn on Display period in the panel path. */ - viafb_write_reg_mask(CR91, VIACR, 0, BIT7); - - /* Turn on TMDS power. */ - viafb_write_reg_mask(CRD2, VIACR, 0, BIT3); - break; - } - - if (viaparinfo->tmds_setting_info->iga_path == IGA2) { - /* Disable LCD Scaling */ - viafb_write_reg_mask(CR79, VIACR, 0x00, BIT0); - } -} diff --git a/drivers/video/via/dvi.h b/drivers/video/via/dvi.h deleted file mode 100644 index 2c525c0c1ad..00000000000 --- a/drivers/video/via/dvi.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 __DVI_H__ -#define __DVI_H__ - -/*Definition TMDS Device ID register*/ -#define VT1632_DEVICE_ID_REG 0x02 -#define VT1632_DEVICE_ID 0x92 - -#define GET_DVI_SIZE_BY_SYSTEM_BIOS 0x01 -#define GET_DVI_SIZE_BY_VGA_BIOS 0x02 -#define GET_DVI_SZIE_BY_HW_STRAPPING 0x03 - -/* Definition DVI Panel ID*/ -/* Resolution: 640x480, Channel: single, Dithering: Enable */ -#define DVI_PANEL_ID0_640X480 0x00 -/* Resolution: 800x600, Channel: single, Dithering: Enable */ -#define DVI_PANEL_ID1_800x600 0x01 -/* Resolution: 1024x768, Channel: single, Dithering: Enable */ -#define DVI_PANEL_ID1_1024x768 0x02 -/* Resolution: 1280x768, Channel: single, Dithering: Enable */ -#define DVI_PANEL_ID1_1280x768 0x03 -/* Resolution: 1280x1024, Channel: dual, Dithering: Enable */ -#define DVI_PANEL_ID1_1280x1024 0x04 -/* Resolution: 1400x1050, Channel: dual, Dithering: Enable */ -#define DVI_PANEL_ID1_1400x1050 0x05 -/* Resolution: 1600x1200, Channel: dual, Dithering: Enable */ -#define DVI_PANEL_ID1_1600x1200 0x06 - -/* Define the version of EDID*/ -#define EDID_VERSION_1 1 -#define EDID_VERSION_2 2 - -#define DEV_CONNECT_DVI 0x01 -#define DEV_CONNECT_HDMI 0x02 - -int viafb_dvi_sense(void); -void viafb_dvi_disable(void); -void viafb_dvi_enable(void); -int __devinit viafb_tmds_trasmitter_identify(void); -void __devinit viafb_init_dvi_size(struct tmds_chip_information *tmds_chip, - struct tmds_setting_information *tmds_setting); -void viafb_dvi_set_mode(struct VideoModeTable *videoMode, int mode_bpp, - int set_iga); - -#endif /* __DVI_H__ */ diff --git a/drivers/video/via/global.c b/drivers/video/via/global.c deleted file mode 100644 index 1ee511b7330..00000000000 --- a/drivers/video/via/global.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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_platform_epia_dvi = STATE_OFF; -int viafb_device_lcd_dualedge = STATE_OFF; -int viafb_bus_width = 12; -int viafb_display_hardware_layout = HW_LAYOUT_LCD_DVI; -int viafb_DeviceStatus = CRT_Device; -int viafb_hotplug; -int viafb_refresh = 60; -int viafb_refresh1 = 60; -int viafb_lcd_dsp_method = LCD_EXPANDSION; -int viafb_lcd_mode = LCD_OPENLDI; -int viafb_CRT_ON = 1; -int viafb_DVI_ON; -int viafb_LCD_ON ; -int viafb_LCD2_ON; -int viafb_SAMM_ON; -int viafb_dual_fb; -int viafb_hotplug_Xres = 640; -int viafb_hotplug_Yres = 480; -int viafb_hotplug_bpp = 32; -int viafb_hotplug_refresh = 60; -int viafb_primary_dev = None_Device; -unsigned int viafb_second_xres = 640; -unsigned int viafb_second_yres = 480; -unsigned int viafb_second_virtual_xres; -unsigned int viafb_second_virtual_yres; -int viafb_lcd_panel_id = LCD_PANEL_ID_MAXIMUM + 1; -struct fb_info *viafbinfo; -struct fb_info *viafbinfo1; -struct viafb_par *viaparinfo; -struct viafb_par *viaparinfo1; - diff --git a/drivers/video/via/global.h b/drivers/video/via/global.h deleted file mode 100644 index 38ef5ac6695..00000000000 --- a/drivers/video/via/global.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 __GLOBAL_H__ -#define __GLOBAL_H__ - -#include <linux/fb.h> -#include <linux/delay.h> -#include <linux/ioport.h> -#include <linux/pci.h> -#include <linux/io.h> -#include <linux/uaccess.h> -#include <linux/init.h> -#include <linux/proc_fs.h> -#include <linux/console.h> -#include <linux/timer.h> - -#include "debug.h" - -#include "viafbdev.h" -#include "chip.h" -#include "accel.h" -#include "share.h" -#include "dvi.h" -#include "viamode.h" -#include "hw.h" - -#include "lcd.h" -#include "ioctl.h" -#include "via_utility.h" -#include "vt1636.h" -#include "tblDPASetting.h" - -/* External struct*/ - -extern int viafb_platform_epia_dvi; -extern int viafb_device_lcd_dualedge; -extern int viafb_bus_width; -extern int viafb_display_hardware_layout; -extern struct offset offset_reg; -extern struct viafb_par *viaparinfo; -extern struct viafb_par *viaparinfo1; -extern struct fb_info *viafbinfo; -extern struct fb_info *viafbinfo1; -extern int viafb_DeviceStatus; -extern int viafb_refresh; -extern int viafb_refresh1; -extern int viafb_lcd_dsp_method; -extern int viafb_lcd_mode; - -extern int viafb_CRT_ON; -extern int viafb_hotplug_Xres; -extern int viafb_hotplug_Yres; -extern int viafb_hotplug_bpp; -extern int viafb_hotplug_refresh; -extern int viafb_primary_dev; - -extern unsigned int viafb_second_xres; -extern unsigned int viafb_second_yres; -extern int viafb_lcd_panel_id; - -#endif /* __GLOBAL_H__ */ diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c deleted file mode 100644 index 36d73f940d8..00000000000 --- a/drivers/video/via/hw.c +++ /dev/null @@ -1,2761 +0,0 @@ -/* - * 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 <linux/via-core.h> -#include "global.h" - -static struct pll_map pll_value[] = { - {25175000, - {99, 7, 3}, - {85, 3, 4}, /* ignoring bit difference: 0x00008000 */ - {141, 5, 4}, - {141, 5, 4} }, - {29581000, - {33, 4, 2}, - {66, 2, 4}, /* ignoring bit difference: 0x00808000 */ - {166, 5, 4}, /* ignoring bit difference: 0x00008000 */ - {165, 5, 4} }, - {26880000, - {15, 4, 1}, - {30, 2, 3}, /* ignoring bit difference: 0x00808000 */ - {150, 5, 4}, - {150, 5, 4} }, - {31500000, - {53, 3, 3}, /* ignoring bit difference: 0x00008000 */ - {141, 4, 4}, /* ignoring bit difference: 0x00008000 */ - {176, 5, 4}, - {176, 5, 4} }, - {31728000, - {31, 7, 1}, - {177, 5, 4}, /* ignoring bit difference: 0x00008000 */ - {177, 5, 4}, - {142, 4, 4} }, - {32688000, - {73, 4, 3}, - {146, 4, 4}, /* ignoring bit difference: 0x00008000 */ - {183, 5, 4}, - {146, 4, 4} }, - {36000000, - {101, 5, 3}, /* ignoring bit difference: 0x00008000 */ - {161, 4, 4}, /* ignoring bit difference: 0x00008000 */ - {202, 5, 4}, - {161, 4, 4} }, - {40000000, - {89, 4, 3}, - {89, 4, 3}, /* ignoring bit difference: 0x00008000 */ - {112, 5, 3}, - {112, 5, 3} }, - {41291000, - {23, 4, 1}, - {69, 3, 3}, /* ignoring bit difference: 0x00008000 */ - {115, 5, 3}, - {115, 5, 3} }, - {43163000, - {121, 5, 3}, - {121, 5, 3}, /* ignoring bit difference: 0x00008000 */ - {121, 5, 3}, - {121, 5, 3} }, - {45250000, - {127, 5, 3}, - {127, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {127, 5, 3}, - {127, 5, 3} }, - {46000000, - {90, 7, 2}, - {103, 4, 3}, /* ignoring bit difference: 0x00008000 */ - {129, 5, 3}, - {103, 4, 3} }, - {46996000, - {105, 4, 3}, /* ignoring bit difference: 0x00008000 */ - {131, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {131, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {105, 4, 3} }, - {48000000, - {67, 20, 0}, - {134, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {134, 5, 3}, - {134, 5, 3} }, - {48875000, - {99, 29, 0}, - {82, 3, 3}, /* ignoring bit difference: 0x00808000 */ - {82, 3, 3}, /* ignoring bit difference: 0x00808000 */ - {137, 5, 3} }, - {49500000, - {83, 6, 2}, - {83, 3, 3}, /* ignoring bit difference: 0x00008000 */ - {138, 5, 3}, - {83, 3, 3} }, - {52406000, - {117, 4, 3}, - {117, 4, 3}, /* ignoring bit difference: 0x00008000 */ - {117, 4, 3}, - {88, 3, 3} }, - {52977000, - {37, 5, 1}, - {148, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {148, 5, 3}, - {148, 5, 3} }, - {56250000, - {55, 7, 1}, /* ignoring bit difference: 0x00008000 */ - {126, 4, 3}, /* ignoring bit difference: 0x00008000 */ - {157, 5, 3}, - {157, 5, 3} }, - {57275000, - {0, 0, 0}, - {2, 2, 0}, - {2, 2, 0}, - {157, 5, 3} }, /* ignoring bit difference: 0x00808000 */ - {60466000, - {76, 9, 1}, - {169, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {169, 5, 3}, /* FIXED: old = {72, 2, 3} */ - {169, 5, 3} }, - {61500000, - {86, 20, 0}, - {172, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {172, 5, 3}, - {172, 5, 3} }, - {65000000, - {109, 6, 2}, /* ignoring bit difference: 0x00008000 */ - {109, 3, 3}, /* ignoring bit difference: 0x00008000 */ - {109, 3, 3}, - {109, 3, 3} }, - {65178000, - {91, 5, 2}, - {182, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {109, 3, 3}, - {182, 5, 3} }, - {66750000, - {75, 4, 2}, - {150, 4, 3}, /* ignoring bit difference: 0x00808000 */ - {150, 4, 3}, - {112, 3, 3} }, - {68179000, - {19, 4, 0}, - {114, 3, 3}, /* ignoring bit difference: 0x00008000 */ - {190, 5, 3}, - {191, 5, 3} }, - {69924000, - {83, 17, 0}, - {195, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {195, 5, 3}, - {195, 5, 3} }, - {70159000, - {98, 20, 0}, - {196, 5, 3}, /* ignoring bit difference: 0x00808000 */ - {196, 5, 3}, - {195, 5, 3} }, - {72000000, - {121, 24, 0}, - {161, 4, 3}, /* ignoring bit difference: 0x00808000 */ - {161, 4, 3}, - {161, 4, 3} }, - {78750000, - {33, 3, 1}, - {66, 3, 2}, /* ignoring bit difference: 0x00008000 */ - {110, 5, 2}, - {110, 5, 2} }, - {80136000, - {28, 5, 0}, - {68, 3, 2}, /* ignoring bit difference: 0x00008000 */ - {112, 5, 2}, - {112, 5, 2} }, - {83375000, - {93, 2, 3}, - {93, 4, 2}, /* ignoring bit difference: 0x00800000 */ - {93, 4, 2}, /* ignoring bit difference: 0x00800000 */ - {117, 5, 2} }, - {83950000, - {41, 7, 0}, - {117, 5, 2}, /* ignoring bit difference: 0x00008000 */ - {117, 5, 2}, - {117, 5, 2} }, - {84750000, - {118, 5, 2}, - {118, 5, 2}, /* ignoring bit difference: 0x00808000 */ - {118, 5, 2}, - {118, 5, 2} }, - {85860000, - {84, 7, 1}, - {120, 5, 2}, /* ignoring bit difference: 0x00808000 */ - {120, 5, 2}, - {118, 5, 2} }, - {88750000, - {31, 5, 0}, - {124, 5, 2}, /* ignoring bit difference: 0x00808000 */ - {174, 7, 2}, /* ignoring bit difference: 0x00808000 */ - {124, 5, 2} }, - {94500000, - {33, 5, 0}, - {132, 5, 2}, /* ignoring bit difference: 0x00008000 */ - {132, 5, 2}, - {132, 5, 2} }, - {97750000, - {82, 6, 1}, - {137, 5, 2}, /* ignoring bit difference: 0x00808000 */ - {137, 5, 2}, - {137, 5, 2} }, - {101000000, - {127, 9, 1}, - {141, 5, 2}, /* ignoring bit difference: 0x00808000 */ - {141, 5, 2}, - {141, 5, 2} }, - {106500000, - {119, 4, 2}, - {119, 4, 2}, /* ignoring bit difference: 0x00808000 */ - {119, 4, 2}, - {149, 5, 2} }, - {108000000, - {121, 4, 2}, - {121, 4, 2}, /* ignoring bit difference: 0x00808000 */ - {151, 5, 2}, - {151, 5, 2} }, - {113309000, - {95, 12, 0}, - {95, 3, 2}, /* ignoring bit difference: 0x00808000 */ - {95, 3, 2}, - {159, 5, 2} }, - {118840000, - {83, 5, 1}, - {166, 5, 2}, /* ignoring bit difference: 0x00808000 */ - {166, 5, 2}, - {166, 5, 2} }, - {119000000, - {108, 13, 0}, - {133, 4, 2}, /* ignoring bit difference: 0x00808000 */ - {133, 4, 2}, - {167, 5, 2} }, - {121750000, - {85, 5, 1}, - {170, 5, 2}, /* ignoring bit difference: 0x00808000 */ - {68, 2, 2}, - {0, 0, 0} }, - {125104000, - {53, 6, 0}, /* ignoring bit difference: 0x00008000 */ - {106, 3, 2}, /* ignoring bit difference: 0x00008000 */ - {175, 5, 2}, - {0, 0, 0} }, - {135000000, - {94, 5, 1}, - {28, 3, 0}, /* ignoring bit difference: 0x00804000 */ - {151, 4, 2}, - {189, 5, 2} }, - {136700000, - {115, 12, 0}, - {191, 5, 2}, /* ignoring bit difference: 0x00808000 */ - {191, 5, 2}, - {191, 5, 2} }, - {138400000, - {87, 9, 0}, - {116, 3, 2}, /* ignoring bit difference: 0x00808000 */ - {116, 3, 2}, - {194, 5, 2} }, - {146760000, - {103, 5, 1}, - {206, 5, 2}, /* ignoring bit difference: 0x00808000 */ - {206, 5, 2}, - {206, 5, 2} }, - {153920000, - {86, 8, 0}, - {86, 4, 1}, /* ignoring bit difference: 0x00808000 */ - {86, 4, 1}, - {86, 4, 1} }, /* FIXED: old = {84, 2, 1} */ - {156000000, - {109, 5, 1}, - {109, 5, 1}, /* ignoring bit difference: 0x00808000 */ - {109, 5, 1}, - {108, 5, 1} }, - {157500000, - {55, 5, 0}, /* ignoring bit difference: 0x00008000 */ - {22, 2, 0}, /* ignoring bit difference: 0x00802000 */ - {110, 5, 1}, - {110, 5, 1} }, - {162000000, - {113, 5, 1}, - {113, 5, 1}, /* ignoring bit difference: 0x00808000 */ - {113, 5, 1}, - {113, 5, 1} }, - {187000000, - {118, 9, 0}, - {131, 5, 1}, /* ignoring bit difference: 0x00808000 */ - {131, 5, 1}, - {131, 5, 1} }, - {193295000, - {108, 8, 0}, - {81, 3, 1}, /* ignoring bit difference: 0x00808000 */ - {135, 5, 1}, - {135, 5, 1} }, - {202500000, - {99, 7, 0}, - {85, 3, 1}, /* ignoring bit difference: 0x00808000 */ - {142, 5, 1}, - {142, 5, 1} }, - {204000000, - {100, 7, 0}, - {143, 5, 1}, /* ignoring bit difference: 0x00808000 */ - {143, 5, 1}, - {143, 5, 1} }, - {218500000, - {92, 6, 0}, - {153, 5, 1}, /* ignoring bit difference: 0x00808000 */ - {153, 5, 1}, - {153, 5, 1} }, - {234000000, - {98, 6, 0}, - {98, 3, 1}, /* ignoring bit difference: 0x00008000 */ - {98, 3, 1}, - {164, 5, 1} }, - {267250000, - {112, 6, 0}, - {112, 3, 1}, /* ignoring bit difference: 0x00808000 */ - {187, 5, 1}, - {187, 5, 1} }, - {297500000, - {102, 5, 0}, /* ignoring bit difference: 0x00008000 */ - {166, 4, 1}, /* ignoring bit difference: 0x00008000 */ - {208, 5, 1}, - {208, 5, 1} }, - {74481000, - {26, 5, 0}, - {125, 3, 3}, /* ignoring bit difference: 0x00808000 */ - {208, 5, 3}, - {209, 5, 3} }, - {172798000, - {121, 5, 1}, - {121, 5, 1}, /* ignoring bit difference: 0x00808000 */ - {121, 5, 1}, - {121, 5, 1} }, - {122614000, - {60, 7, 0}, - {137, 4, 2}, /* ignoring bit difference: 0x00808000 */ - {137, 4, 2}, - {172, 5, 2} }, - {74270000, - {83, 8, 1}, - {208, 5, 3}, - {208, 5, 3}, - {0, 0, 0} }, - {148500000, - {83, 8, 0}, - {208, 5, 2}, - {166, 4, 2}, - {208, 5, 2} } -}; - -static struct fifo_depth_select display_fifo_depth_reg = { - /* IGA1 FIFO Depth_Select */ - {IGA1_FIFO_DEPTH_SELECT_REG_NUM, {{SR17, 0, 7} } }, - /* IGA2 FIFO Depth_Select */ - {IGA2_FIFO_DEPTH_SELECT_REG_NUM, - {{CR68, 4, 7}, {CR94, 7, 7}, {CR95, 7, 7} } } -}; - -static struct fifo_threshold_select fifo_threshold_select_reg = { - /* IGA1 FIFO Threshold Select */ - {IGA1_FIFO_THRESHOLD_REG_NUM, {{SR16, 0, 5}, {SR16, 7, 7} } }, - /* IGA2 FIFO Threshold Select */ - {IGA2_FIFO_THRESHOLD_REG_NUM, {{CR68, 0, 3}, {CR95, 4, 6} } } -}; - -static struct fifo_high_threshold_select fifo_high_threshold_select_reg = { - /* IGA1 FIFO High Threshold Select */ - {IGA1_FIFO_HIGH_THRESHOLD_REG_NUM, {{SR18, 0, 5}, {SR18, 7, 7} } }, - /* IGA2 FIFO High Threshold Select */ - {IGA2_FIFO_HIGH_THRESHOLD_REG_NUM, {{CR92, 0, 3}, {CR95, 0, 2} } } -}; - -static struct display_queue_expire_num display_queue_expire_num_reg = { - /* IGA1 Display Queue Expire Num */ - {IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM, {{SR22, 0, 4} } }, - /* IGA2 Display Queue Expire Num */ - {IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM, {{CR94, 0, 6} } } -}; - -/* Definition Fetch Count Registers*/ -static struct fetch_count fetch_count_reg = { - /* IGA1 Fetch Count Register */ - {IGA1_FETCH_COUNT_REG_NUM, {{SR1C, 0, 7}, {SR1D, 0, 1} } }, - /* IGA2 Fetch Count Register */ - {IGA2_FETCH_COUNT_REG_NUM, {{CR65, 0, 7}, {CR67, 2, 3} } } -}; - -static struct iga1_crtc_timing iga1_crtc_reg = { - /* IGA1 Horizontal Total */ - {IGA1_HOR_TOTAL_REG_NUM, {{CR00, 0, 7}, {CR36, 3, 3} } }, - /* IGA1 Horizontal Addressable Video */ - {IGA1_HOR_ADDR_REG_NUM, {{CR01, 0, 7} } }, - /* IGA1 Horizontal Blank Start */ - {IGA1_HOR_BLANK_START_REG_NUM, {{CR02, 0, 7} } }, - /* IGA1 Horizontal Blank End */ - {IGA1_HOR_BLANK_END_REG_NUM, - {{CR03, 0, 4}, {CR05, 7, 7}, {CR33, 5, 5} } }, - /* IGA1 Horizontal Sync Start */ - {IGA1_HOR_SYNC_START_REG_NUM, {{CR04, 0, 7}, {CR33, 4, 4} } }, - /* IGA1 Horizontal Sync End */ - {IGA1_HOR_SYNC_END_REG_NUM, {{CR05, 0, 4} } }, - /* IGA1 Vertical Total */ - {IGA1_VER_TOTAL_REG_NUM, - {{CR06, 0, 7}, {CR07, 0, 0}, {CR07, 5, 5}, {CR35, 0, 0} } }, - /* IGA1 Vertical Addressable Video */ - {IGA1_VER_ADDR_REG_NUM, - {{CR12, 0, 7}, {CR07, 1, 1}, {CR07, 6, 6}, {CR35, 2, 2} } }, - /* IGA1 Vertical Blank Start */ - {IGA1_VER_BLANK_START_REG_NUM, - {{CR15, 0, 7}, {CR07, 3, 3}, {CR09, 5, 5}, {CR35, 3, 3} } }, - /* IGA1 Vertical Blank End */ - {IGA1_VER_BLANK_END_REG_NUM, {{CR16, 0, 7} } }, - /* IGA1 Vertical Sync Start */ - {IGA1_VER_SYNC_START_REG_NUM, - {{CR10, 0, 7}, {CR07, 2, 2}, {CR07, 7, 7}, {CR35, 1, 1} } }, - /* IGA1 Vertical Sync End */ - {IGA1_VER_SYNC_END_REG_NUM, {{CR11, 0, 3} } } -}; - -static struct iga2_crtc_timing iga2_crtc_reg = { - /* IGA2 Horizontal Total */ - {IGA2_HOR_TOTAL_REG_NUM, {{CR50, 0, 7}, {CR55, 0, 3} } }, - /* IGA2 Horizontal Addressable Video */ - {IGA2_HOR_ADDR_REG_NUM, {{CR51, 0, 7}, {CR55, 4, 6} } }, - /* IGA2 Horizontal Blank Start */ - {IGA2_HOR_BLANK_START_REG_NUM, {{CR52, 0, 7}, {CR54, 0, 2} } }, - /* IGA2 Horizontal Blank End */ - {IGA2_HOR_BLANK_END_REG_NUM, - {{CR53, 0, 7}, {CR54, 3, 5}, {CR5D, 6, 6} } }, - /* IGA2 Horizontal Sync Start */ - {IGA2_HOR_SYNC_START_REG_NUM, - {{CR56, 0, 7}, {CR54, 6, 7}, {CR5C, 7, 7}, {CR5D, 7, 7} } }, - /* IGA2 Horizontal Sync End */ - {IGA2_HOR_SYNC_END_REG_NUM, {{CR57, 0, 7}, {CR5C, 6, 6} } }, - /* IGA2 Vertical Total */ - {IGA2_VER_TOTAL_REG_NUM, {{CR58, 0, 7}, {CR5D, 0, 2} } }, - /* IGA2 Vertical Addressable Video */ - {IGA2_VER_ADDR_REG_NUM, {{CR59, 0, 7}, {CR5D, 3, 5} } }, - /* IGA2 Vertical Blank Start */ - {IGA2_VER_BLANK_START_REG_NUM, {{CR5A, 0, 7}, {CR5C, 0, 2} } }, - /* IGA2 Vertical Blank End */ - {IGA2_VER_BLANK_END_REG_NUM, {{CR5B, 0, 7}, {CR5C, 3, 5} } }, - /* IGA2 Vertical Sync Start */ - {IGA2_VER_SYNC_START_REG_NUM, {{CR5E, 0, 7}, {CR5F, 5, 7} } }, - /* IGA2 Vertical Sync End */ - {IGA2_VER_SYNC_END_REG_NUM, {{CR5F, 0, 4} } } -}; - -static struct rgbLUT palLUT_table[] = { - /* {R,G,B} */ - /* Index 0x00~0x03 */ - {0x00, 0x00, 0x00}, {0x00, 0x00, 0x2A}, {0x00, 0x2A, 0x00}, {0x00, - 0x2A, - 0x2A}, - /* Index 0x04~0x07 */ - {0x2A, 0x00, 0x00}, {0x2A, 0x00, 0x2A}, {0x2A, 0x15, 0x00}, {0x2A, - 0x2A, - 0x2A}, - /* Index 0x08~0x0B */ - {0x15, 0x15, 0x15}, {0x15, 0x15, 0x3F}, {0x15, 0x3F, 0x15}, {0x15, - 0x3F, - 0x3F}, - /* Index 0x0C~0x0F */ - {0x3F, 0x15, 0x15}, {0x3F, 0x15, 0x3F}, {0x3F, 0x3F, 0x15}, {0x3F, - 0x3F, - 0x3F}, - /* Index 0x10~0x13 */ - {0x00, 0x00, 0x00}, {0x05, 0x05, 0x05}, {0x08, 0x08, 0x08}, {0x0B, - 0x0B, - 0x0B}, - /* Index 0x14~0x17 */ - {0x0E, 0x0E, 0x0E}, {0x11, 0x11, 0x11}, {0x14, 0x14, 0x14}, {0x18, - 0x18, - 0x18}, - /* Index 0x18~0x1B */ - {0x1C, 0x1C, 0x1C}, {0x20, 0x20, 0x20}, {0x24, 0x24, 0x24}, {0x28, - 0x28, - 0x28}, - /* Index 0x1C~0x1F */ - {0x2D, 0x2D, 0x2D}, {0x32, 0x32, 0x32}, {0x38, 0x38, 0x38}, {0x3F, - 0x3F, - 0x3F}, - /* Index 0x20~0x23 */ - {0x00, 0x00, 0x3F}, {0x10, 0x00, 0x3F}, {0x1F, 0x00, 0x3F}, {0x2F, - 0x00, - 0x3F}, - /* Index 0x24~0x27 */ - {0x3F, 0x00, 0x3F}, {0x3F, 0x00, 0x2F}, {0x3F, 0x00, 0x1F}, {0x3F, - 0x00, - 0x10}, - /* Index 0x28~0x2B */ - {0x3F, 0x00, 0x00}, {0x3F, 0x10, 0x00}, {0x3F, 0x1F, 0x00}, {0x3F, - 0x2F, - 0x00}, - /* Index 0x2C~0x2F */ - {0x3F, 0x3F, 0x00}, {0x2F, 0x3F, 0x00}, {0x1F, 0x3F, 0x00}, {0x10, - 0x3F, - 0x00}, - /* Index 0x30~0x33 */ - {0x00, 0x3F, 0x00}, {0x00, 0x3F, 0x10}, {0x00, 0x3F, 0x1F}, {0x00, - 0x3F, - 0x2F}, - /* Index 0x34~0x37 */ - {0x00, 0x3F, 0x3F}, {0x00, 0x2F, 0x3F}, {0x00, 0x1F, 0x3F}, {0x00, - 0x10, - 0x3F}, - /* Index 0x38~0x3B */ - {0x1F, 0x1F, 0x3F}, {0x27, 0x1F, 0x3F}, {0x2F, 0x1F, 0x3F}, {0x37, - 0x1F, - 0x3F}, - /* Index 0x3C~0x3F */ - {0x3F, 0x1F, 0x3F}, {0x3F, 0x1F, 0x37}, {0x3F, 0x1F, 0x2F}, {0x3F, - 0x1F, - 0x27}, - /* Index 0x40~0x43 */ - {0x3F, 0x1F, 0x1F}, {0x3F, 0x27, 0x1F}, {0x3F, 0x2F, 0x1F}, {0x3F, - 0x3F, - 0x1F}, - /* Index 0x44~0x47 */ - {0x3F, 0x3F, 0x1F}, {0x37, 0x3F, 0x1F}, {0x2F, 0x3F, 0x1F}, {0x27, - 0x3F, - 0x1F}, - /* Index 0x48~0x4B */ - {0x1F, 0x3F, 0x1F}, {0x1F, 0x3F, 0x27}, {0x1F, 0x3F, 0x2F}, {0x1F, - 0x3F, - 0x37}, - /* Index 0x4C~0x4F */ - {0x1F, 0x3F, 0x3F}, {0x1F, 0x37, 0x3F}, {0x1F, 0x2F, 0x3F}, {0x1F, - 0x27, - 0x3F}, - /* Index 0x50~0x53 */ - {0x2D, 0x2D, 0x3F}, {0x31, 0x2D, 0x3F}, {0x36, 0x2D, 0x3F}, {0x3A, - 0x2D, - 0x3F}, - /* Index 0x54~0x57 */ - {0x3F, 0x2D, 0x3F}, {0x3F, 0x2D, 0x3A}, {0x3F, 0x2D, 0x36}, {0x3F, - 0x2D, - 0x31}, - /* Index 0x58~0x5B */ - {0x3F, 0x2D, 0x2D}, {0x3F, 0x31, 0x2D}, {0x3F, 0x36, 0x2D}, {0x3F, - 0x3A, - 0x2D}, - /* Index 0x5C~0x5F */ - {0x3F, 0x3F, 0x2D}, {0x3A, 0x3F, 0x2D}, {0x36, 0x3F, 0x2D}, {0x31, - 0x3F, - 0x2D}, - /* Index 0x60~0x63 */ - {0x2D, 0x3F, 0x2D}, {0x2D, 0x3F, 0x31}, {0x2D, 0x3F, 0x36}, {0x2D, - 0x3F, - 0x3A}, - /* Index 0x64~0x67 */ - {0x2D, 0x3F, 0x3F}, {0x2D, 0x3A, 0x3F}, {0x2D, 0x36, 0x3F}, {0x2D, - 0x31, - 0x3F}, - /* Index 0x68~0x6B */ - {0x00, 0x00, 0x1C}, {0x07, 0x00, 0x1C}, {0x0E, 0x00, 0x1C}, {0x15, - 0x00, - 0x1C}, - /* Index 0x6C~0x6F */ - {0x1C, 0x00, 0x1C}, {0x1C, 0x00, 0x15}, {0x1C, 0x00, 0x0E}, {0x1C, - 0x00, - 0x07}, - /* Index 0x70~0x73 */ - {0x1C, 0x00, 0x00}, {0x1C, 0x07, 0x00}, {0x1C, 0x0E, 0x00}, {0x1C, - 0x15, - 0x00}, - /* Index 0x74~0x77 */ - {0x1C, 0x1C, 0x00}, {0x15, 0x1C, 0x00}, {0x0E, 0x1C, 0x00}, {0x07, - 0x1C, - 0x00}, - /* Index 0x78~0x7B */ - {0x00, 0x1C, 0x00}, {0x00, 0x1C, 0x07}, {0x00, 0x1C, 0x0E}, {0x00, - 0x1C, - 0x15}, - /* Index 0x7C~0x7F */ - {0x00, 0x1C, 0x1C}, {0x00, 0x15, 0x1C}, {0x00, 0x0E, 0x1C}, {0x00, - 0x07, - 0x1C}, - /* Index 0x80~0x83 */ - {0x0E, 0x0E, 0x1C}, {0x11, 0x0E, 0x1C}, {0x15, 0x0E, 0x1C}, {0x18, - 0x0E, - 0x1C}, - /* Index 0x84~0x87 */ - {0x1C, 0x0E, 0x1C}, {0x1C, 0x0E, 0x18}, {0x1C, 0x0E, 0x15}, {0x1C, - 0x0E, - 0x11}, - /* Index 0x88~0x8B */ - {0x1C, 0x0E, 0x0E}, {0x1C, 0x11, 0x0E}, {0x1C, 0x15, 0x0E}, {0x1C, - 0x18, - 0x0E}, - /* Index 0x8C~0x8F */ - {0x1C, 0x1C, 0x0E}, {0x18, 0x1C, 0x0E}, {0x15, 0x1C, 0x0E}, {0x11, - 0x1C, - 0x0E}, - /* Index 0x90~0x93 */ - {0x0E, 0x1C, 0x0E}, {0x0E, 0x1C, 0x11}, {0x0E, 0x1C, 0x15}, {0x0E, - 0x1C, - 0x18}, - /* Index 0x94~0x97 */ - {0x0E, 0x1C, 0x1C}, {0x0E, 0x18, 0x1C}, {0x0E, 0x15, 0x1C}, {0x0E, - 0x11, - 0x1C}, - /* Index 0x98~0x9B */ - {0x14, 0x14, 0x1C}, {0x16, 0x14, 0x1C}, {0x18, 0x14, 0x1C}, {0x1A, - 0x14, - 0x1C}, - /* Index 0x9C~0x9F */ - {0x1C, 0x14, 0x1C}, {0x1C, 0x14, 0x1A}, {0x1C, 0x14, 0x18}, {0x1C, - 0x14, - 0x16}, - /* Index 0xA0~0xA3 */ - {0x1C, 0x14, 0x14}, {0x1C, 0x16, 0x14}, {0x1C, 0x18, 0x14}, {0x1C, - 0x1A, - 0x14}, - /* Index 0xA4~0xA7 */ - {0x1C, 0x1C, 0x14}, {0x1A, 0x1C, 0x14}, {0x18, 0x1C, 0x14}, {0x16, - 0x1C, - 0x14}, - /* Index 0xA8~0xAB */ - {0x14, 0x1C, 0x14}, {0x14, 0x1C, 0x16}, {0x14, 0x1C, 0x18}, {0x14, - 0x1C, - 0x1A}, - /* Index 0xAC~0xAF */ - {0x14, 0x1C, 0x1C}, {0x14, 0x1A, 0x1C}, {0x14, 0x18, 0x1C}, {0x14, - 0x16, - 0x1C}, - /* Index 0xB0~0xB3 */ - {0x00, 0x00, 0x10}, {0x04, 0x00, 0x10}, {0x08, 0x00, 0x10}, {0x0C, - 0x00, - 0x10}, - /* Index 0xB4~0xB7 */ - {0x10, 0x00, 0x10}, {0x10, 0x00, 0x0C}, {0x10, 0x00, 0x08}, {0x10, - 0x00, - 0x04}, - /* Index 0xB8~0xBB */ - {0x10, 0x00, 0x00}, {0x10, 0x04, 0x00}, {0x10, 0x08, 0x00}, {0x10, - 0x0C, - 0x00}, - /* Index 0xBC~0xBF */ - {0x10, 0x10, 0x00}, {0x0C, 0x10, 0x00}, {0x08, 0x10, 0x00}, {0x04, - 0x10, - 0x00}, - /* Index 0xC0~0xC3 */ - {0x00, 0x10, 0x00}, {0x00, 0x10, 0x04}, {0x00, 0x10, 0x08}, {0x00, - 0x10, - 0x0C}, - /* Index 0xC4~0xC7 */ - {0x00, 0x10, 0x10}, {0x00, 0x0C, 0x10}, {0x00, 0x08, 0x10}, {0x00, - 0x04, - 0x10}, - /* Index 0xC8~0xCB */ - {0x08, 0x08, 0x10}, {0x0A, 0x08, 0x10}, {0x0C, 0x08, 0x10}, {0x0E, - 0x08, - 0x10}, - /* Index 0xCC~0xCF */ - {0x10, 0x08, 0x10}, {0x10, 0x08, 0x0E}, {0x10, 0x08, 0x0C}, {0x10, - 0x08, - 0x0A}, - /* Index 0xD0~0xD3 */ - {0x10, 0x08, 0x08}, {0x10, 0x0A, 0x08}, {0x10, 0x0C, 0x08}, {0x10, - 0x0E, - 0x08}, - /* Index 0xD4~0xD7 */ - {0x10, 0x10, 0x08}, {0x0E, 0x10, 0x08}, {0x0C, 0x10, 0x08}, {0x0A, - 0x10, - 0x08}, - /* Index 0xD8~0xDB */ - {0x08, 0x10, 0x08}, {0x08, 0x10, 0x0A}, {0x08, 0x10, 0x0C}, {0x08, - 0x10, - 0x0E}, - /* Index 0xDC~0xDF */ - {0x08, 0x10, 0x10}, {0x08, 0x0E, 0x10}, {0x08, 0x0C, 0x10}, {0x08, - 0x0A, - 0x10}, - /* Index 0xE0~0xE3 */ - {0x0B, 0x0B, 0x10}, {0x0C, 0x0B, 0x10}, {0x0D, 0x0B, 0x10}, {0x0F, - 0x0B, - 0x10}, - /* Index 0xE4~0xE7 */ - {0x10, 0x0B, 0x10}, {0x10, 0x0B, 0x0F}, {0x10, 0x0B, 0x0D}, {0x10, - 0x0B, - 0x0C}, - /* Index 0xE8~0xEB */ - {0x10, 0x0B, 0x0B}, {0x10, 0x0C, 0x0B}, {0x10, 0x0D, 0x0B}, {0x10, - 0x0F, - 0x0B}, - /* Index 0xEC~0xEF */ - {0x10, 0x10, 0x0B}, {0x0F, 0x10, 0x0B}, {0x0D, 0x10, 0x0B}, {0x0C, - 0x10, - 0x0B}, - /* Index 0xF0~0xF3 */ - {0x0B, 0x10, 0x0B}, {0x0B, 0x10, 0x0C}, {0x0B, 0x10, 0x0D}, {0x0B, - 0x10, - 0x0F}, - /* Index 0xF4~0xF7 */ - {0x0B, 0x10, 0x10}, {0x0B, 0x0F, 0x10}, {0x0B, 0x0D, 0x10}, {0x0B, - 0x0C, - 0x10}, - /* Index 0xF8~0xFB */ - {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00, - 0x00, - 0x00}, - /* Index 0xFC~0xFF */ - {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}, {0x00, - 0x00, - 0x00} -}; - -static struct via_device_mapping device_mapping[] = { - {VIA_LDVP0, "LDVP0"}, - {VIA_LDVP1, "LDVP1"}, - {VIA_DVP0, "DVP0"}, - {VIA_CRT, "CRT"}, - {VIA_DVP1, "DVP1"}, - {VIA_LVDS1, "LVDS1"}, - {VIA_LVDS2, "LVDS2"} -}; - -static void load_fix_bit_crtc_reg(void); -static void __devinit init_gfx_chip_info(int chip_type); -static void __devinit init_tmds_chip_info(void); -static void __devinit init_lvds_chip_info(void); -static void device_screen_off(void); -static void device_screen_on(void); -static void set_display_channel(void); -static void device_off(void); -static void device_on(void); -static void enable_second_display_channel(void); -static void disable_second_display_channel(void); - -void viafb_lock_crt(void) -{ - viafb_write_reg_mask(CR11, VIACR, BIT7, BIT7); -} - -void viafb_unlock_crt(void) -{ - viafb_write_reg_mask(CR11, VIACR, 0, BIT7); - viafb_write_reg_mask(CR47, VIACR, 0, BIT0); -} - -void write_dac_reg(u8 index, u8 r, u8 g, u8 b) -{ - outb(index, LUT_INDEX_WRITE); - outb(r, LUT_DATA); - outb(g, LUT_DATA); - outb(b, LUT_DATA); -} - -static u32 get_dvi_devices(int output_interface) -{ - switch (output_interface) { - case INTERFACE_DVP0: - return VIA_DVP0 | VIA_LDVP0; - - case INTERFACE_DVP1: - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) - return VIA_LDVP1; - else - return VIA_DVP1; - - case INTERFACE_DFP_HIGH: - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) - return 0; - else - return VIA_LVDS2 | VIA_DVP0; - - case INTERFACE_DFP_LOW: - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) - return 0; - else - return VIA_DVP1 | VIA_LVDS1; - - case INTERFACE_TMDS: - return VIA_LVDS1; - } - - return 0; -} - -static u32 get_lcd_devices(int output_interface) -{ - switch (output_interface) { - case INTERFACE_DVP0: - return VIA_DVP0; - - case INTERFACE_DVP1: - return VIA_DVP1; - - case INTERFACE_DFP_HIGH: - return VIA_LVDS2 | VIA_DVP0; - - case INTERFACE_DFP_LOW: - return VIA_LVDS1 | VIA_DVP1; - - case INTERFACE_DFP: - return VIA_LVDS1 | VIA_LVDS2; - - case INTERFACE_LVDS0: - case INTERFACE_LVDS0LVDS1: - return VIA_LVDS1; - - case INTERFACE_LVDS1: - return VIA_LVDS2; - } - - return 0; -} - -/*Set IGA path for each device*/ -void viafb_set_iga_path(void) -{ - - if (viafb_SAMM_ON == 1) { - if (viafb_CRT_ON) { - if (viafb_primary_dev == CRT_Device) - viaparinfo->crt_setting_info->iga_path = IGA1; - else - viaparinfo->crt_setting_info->iga_path = IGA2; - } - - if (viafb_DVI_ON) { - if (viafb_primary_dev == DVI_Device) - viaparinfo->tmds_setting_info->iga_path = IGA1; - else - viaparinfo->tmds_setting_info->iga_path = IGA2; - } - - if (viafb_LCD_ON) { - if (viafb_primary_dev == LCD_Device) { - if (viafb_dual_fb && - (viaparinfo->chip_info->gfx_chip_name == - UNICHROME_CLE266)) { - viaparinfo-> - lvds_setting_info->iga_path = IGA2; - viaparinfo-> - crt_setting_info->iga_path = IGA1; - viaparinfo-> - tmds_setting_info->iga_path = IGA1; - } else - viaparinfo-> - lvds_setting_info->iga_path = IGA1; - } else { - viaparinfo->lvds_setting_info->iga_path = IGA2; - } - } - if (viafb_LCD2_ON) { - if (LCD2_Device == viafb_primary_dev) - viaparinfo->lvds_setting_info2->iga_path = IGA1; - else - viaparinfo->lvds_setting_info2->iga_path = IGA2; - } - } else { - viafb_SAMM_ON = 0; - - if (viafb_CRT_ON && viafb_LCD_ON) { - viaparinfo->crt_setting_info->iga_path = IGA1; - viaparinfo->lvds_setting_info->iga_path = IGA2; - } else if (viafb_CRT_ON && viafb_DVI_ON) { - viaparinfo->crt_setting_info->iga_path = IGA1; - viaparinfo->tmds_setting_info->iga_path = IGA2; - } else if (viafb_LCD_ON && viafb_DVI_ON) { - viaparinfo->tmds_setting_info->iga_path = IGA1; - viaparinfo->lvds_setting_info->iga_path = IGA2; - } else if (viafb_LCD_ON && viafb_LCD2_ON) { - viaparinfo->lvds_setting_info->iga_path = IGA2; - viaparinfo->lvds_setting_info2->iga_path = IGA2; - } else if (viafb_CRT_ON) { - viaparinfo->crt_setting_info->iga_path = IGA1; - } else if (viafb_LCD_ON) { - viaparinfo->lvds_setting_info->iga_path = IGA2; - } else if (viafb_DVI_ON) { - viaparinfo->tmds_setting_info->iga_path = IGA1; - } - } - - viaparinfo->shared->iga1_devices = 0; - viaparinfo->shared->iga2_devices = 0; - if (viafb_CRT_ON) { - if (viaparinfo->crt_setting_info->iga_path == IGA1) - viaparinfo->shared->iga1_devices |= VIA_CRT; - else - viaparinfo->shared->iga2_devices |= VIA_CRT; - } - - if (viafb_DVI_ON) { - if (viaparinfo->tmds_setting_info->iga_path == IGA1) - viaparinfo->shared->iga1_devices |= get_dvi_devices( - viaparinfo->chip_info-> - tmds_chip_info.output_interface); - else - viaparinfo->shared->iga2_devices |= get_dvi_devices( - viaparinfo->chip_info-> - tmds_chip_info.output_interface); - } - - if (viafb_LCD_ON) { - if (viaparinfo->lvds_setting_info->iga_path == IGA1) - viaparinfo->shared->iga1_devices |= get_lcd_devices( - viaparinfo->chip_info-> - lvds_chip_info.output_interface); - else - viaparinfo->shared->iga2_devices |= get_lcd_devices( - viaparinfo->chip_info-> - lvds_chip_info.output_interface); - } - - if (viafb_LCD2_ON) { - if (viaparinfo->lvds_setting_info2->iga_path == IGA1) - viaparinfo->shared->iga1_devices |= get_lcd_devices( - viaparinfo->chip_info-> - lvds_chip_info2.output_interface); - else - viaparinfo->shared->iga2_devices |= get_lcd_devices( - viaparinfo->chip_info-> - lvds_chip_info2.output_interface); - } -} - -static void set_color_register(u8 index, u8 red, u8 green, u8 blue) -{ - outb(0xFF, 0x3C6); /* bit mask of palette */ - outb(index, 0x3C8); - outb(red, 0x3C9); - outb(green, 0x3C9); - outb(blue, 0x3C9); -} - -void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue) -{ - viafb_write_reg_mask(0x1A, VIASR, 0x00, 0x01); - set_color_register(index, red, green, blue); -} - -void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue) -{ - viafb_write_reg_mask(0x1A, VIASR, 0x01, 0x01); - set_color_register(index, red, green, blue); -} - -static void set_source_common(u8 index, u8 offset, u8 iga) -{ - u8 value, mask = 1 << offset; - - switch (iga) { - case IGA1: - value = 0x00; - break; - case IGA2: - value = mask; - break; - default: - printk(KERN_WARNING "viafb: Unsupported source: %d\n", iga); - return; - } - - via_write_reg_mask(VIACR, index, value, mask); -} - -static void set_crt_source(u8 iga) -{ - u8 value; - - switch (iga) { - case IGA1: - value = 0x00; - break; - case IGA2: - value = 0x40; - break; - default: - printk(KERN_WARNING "viafb: Unsupported source: %d\n", iga); - return; - } - - via_write_reg_mask(VIASR, 0x16, value, 0x40); -} - -static inline void set_ldvp0_source(u8 iga) -{ - set_source_common(0x6C, 7, iga); -} - -static inline void set_ldvp1_source(u8 iga) -{ - set_source_common(0x93, 7, iga); -} - -static inline void set_dvp0_source(u8 iga) -{ - set_source_common(0x96, 4, iga); -} - -static inline void set_dvp1_source(u8 iga) -{ - set_source_common(0x9B, 4, iga); -} - -static inline void set_lvds1_source(u8 iga) -{ - set_source_common(0x99, 4, iga); -} - -static inline void set_lvds2_source(u8 iga) -{ - set_source_common(0x97, 4, iga); -} - -void via_set_source(u32 devices, u8 iga) -{ - if (devices & VIA_LDVP0) - set_ldvp0_source(iga); - if (devices & VIA_LDVP1) - set_ldvp1_source(iga); - if (devices & VIA_DVP0) - set_dvp0_source(iga); - if (devices & VIA_CRT) - set_crt_source(iga); - if (devices & VIA_DVP1) - set_dvp1_source(iga); - if (devices & VIA_LVDS1) - set_lvds1_source(iga); - if (devices & VIA_LVDS2) - set_lvds2_source(iga); -} - -static void set_crt_state(u8 state) -{ - u8 value; - - switch (state) { - case VIA_STATE_ON: - value = 0x00; - break; - case VIA_STATE_STANDBY: - value = 0x10; - break; - case VIA_STATE_SUSPEND: - value = 0x20; - break; - case VIA_STATE_OFF: - value = 0x30; - break; - default: - return; - } - - via_write_reg_mask(VIACR, 0x36, value, 0x30); -} - -static void set_dvp0_state(u8 state) -{ - u8 value; - - switch (state) { - case VIA_STATE_ON: - value = 0xC0; - break; - case VIA_STATE_OFF: - value = 0x00; - break; - default: - return; - } - - via_write_reg_mask(VIASR, 0x1E, value, 0xC0); -} - -static void set_dvp1_state(u8 state) -{ - u8 value; - - switch (state) { - case VIA_STATE_ON: - value = 0x30; - break; - case VIA_STATE_OFF: - value = 0x00; - break; - default: - return; - } - - via_write_reg_mask(VIASR, 0x1E, value, 0x30); -} - -static void set_lvds1_state(u8 state) -{ - u8 value; - - switch (state) { - case VIA_STATE_ON: - value = 0x03; - break; - case VIA_STATE_OFF: - value = 0x00; - break; - default: - return; - } - - via_write_reg_mask(VIASR, 0x2A, value, 0x03); -} - -static void set_lvds2_state(u8 state) -{ - u8 value; - - switch (state) { - case VIA_STATE_ON: - value = 0x0C; - break; - case VIA_STATE_OFF: - value = 0x00; - break; - default: - return; - } - - via_write_reg_mask(VIASR, 0x2A, value, 0x0C); -} - -void via_set_state(u32 devices, u8 state) -{ - /* - TODO: Can we enable/disable these devices? How? - if (devices & VIA_LDVP0) - if (devices & VIA_LDVP1) - */ - if (devices & VIA_DVP0) - set_dvp0_state(state); - if (devices & VIA_CRT) - set_crt_state(state); - if (devices & VIA_DVP1) - set_dvp1_state(state); - if (devices & VIA_LVDS1) - set_lvds1_state(state); - if (devices & VIA_LVDS2) - set_lvds2_state(state); -} - -void via_set_sync_polarity(u32 devices, u8 polarity) -{ - if (polarity & ~(VIA_HSYNC_NEGATIVE | VIA_VSYNC_NEGATIVE)) { - printk(KERN_WARNING "viafb: Unsupported polarity: %d\n", - polarity); - return; - } - - if (devices & VIA_CRT) - via_write_misc_reg_mask(polarity << 6, 0xC0); - if (devices & VIA_DVP1) - via_write_reg_mask(VIACR, 0x9B, polarity << 5, 0x60); - if (devices & VIA_LVDS1) - via_write_reg_mask(VIACR, 0x99, polarity << 5, 0x60); - if (devices & VIA_LVDS2) - via_write_reg_mask(VIACR, 0x97, polarity << 5, 0x60); -} - -u32 via_parse_odev(char *input, char **end) -{ - char *ptr = input; - u32 odev = 0; - bool next = true; - int i, len; - - while (next) { - next = false; - for (i = 0; i < ARRAY_SIZE(device_mapping); i++) { - len = strlen(device_mapping[i].name); - if (!strncmp(ptr, device_mapping[i].name, len)) { - odev |= device_mapping[i].device; - ptr += len; - if (*ptr == ',') { - ptr++; - next = true; - } - } - } - } - - *end = ptr; - return odev; -} - -void via_odev_to_seq(struct seq_file *m, u32 odev) -{ - int i, count = 0; - - for (i = 0; i < ARRAY_SIZE(device_mapping); i++) { - if (odev & device_mapping[i].device) { - if (count > 0) - seq_putc(m, ','); - - seq_puts(m, device_mapping[i].name); - count++; - } - } - - seq_putc(m, '\n'); -} - -static void load_fix_bit_crtc_reg(void) -{ - /* always set to 1 */ - viafb_write_reg_mask(CR03, VIACR, 0x80, BIT7); - /* line compare should set all bits = 1 (extend modes) */ - viafb_write_reg(CR18, VIACR, 0xff); - /* line compare should set all bits = 1 (extend modes) */ - viafb_write_reg_mask(CR07, VIACR, 0x10, BIT4); - /* line compare should set all bits = 1 (extend modes) */ - viafb_write_reg_mask(CR09, VIACR, 0x40, BIT6); - /* line compare should set all bits = 1 (extend modes) */ - viafb_write_reg_mask(CR35, VIACR, 0x10, BIT4); - /* line compare should set all bits = 1 (extend modes) */ - viafb_write_reg_mask(CR33, VIACR, 0x06, BIT0 + BIT1 + BIT2); - /*viafb_write_reg_mask(CR32, VIACR, 0x01, BIT0); */ - /* extend mode always set to e3h */ - viafb_write_reg(CR17, VIACR, 0xe3); - /* extend mode always set to 0h */ - viafb_write_reg(CR08, VIACR, 0x00); - /* extend mode always set to 0h */ - viafb_write_reg(CR14, VIACR, 0x00); - - /* If K8M800, enable Prefetch Mode. */ - if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) - || (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K8M890)) - viafb_write_reg_mask(CR33, VIACR, 0x08, BIT3); - if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) - && (viaparinfo->chip_info->gfx_chip_revision == CLE266_REVISION_AX)) - viafb_write_reg_mask(SR1A, VIASR, 0x02, BIT1); - -} - -void viafb_load_reg(int timing_value, int viafb_load_reg_num, - struct io_register *reg, - int io_type) -{ - int reg_mask; - int bit_num = 0; - int data; - int i, j; - int shift_next_reg; - int start_index, end_index, cr_index; - u16 get_bit; - - for (i = 0; i < viafb_load_reg_num; i++) { - reg_mask = 0; - data = 0; - start_index = reg[i].start_bit; - end_index = reg[i].end_bit; - cr_index = reg[i].io_addr; - - shift_next_reg = bit_num; - for (j = start_index; j <= end_index; j++) { - /*if (bit_num==8) timing_value = timing_value >>8; */ - reg_mask = reg_mask | (BIT0 << j); - get_bit = (timing_value & (BIT0 << bit_num)); - data = - data | ((get_bit >> shift_next_reg) << start_index); - bit_num++; - } - if (io_type == VIACR) - viafb_write_reg_mask(cr_index, VIACR, data, reg_mask); - else - viafb_write_reg_mask(cr_index, VIASR, data, reg_mask); - } - -} - -/* Write Registers */ -void viafb_write_regx(struct io_reg RegTable[], int ItemNum) -{ - int i; - - /*DEBUG_MSG(KERN_INFO "Table Size : %x!!\n",ItemNum ); */ - - for (i = 0; i < ItemNum; i++) - via_write_reg_mask(RegTable[i].port, RegTable[i].index, - RegTable[i].value, RegTable[i].mask); -} - -void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga) -{ - int reg_value; - int viafb_load_reg_num; - struct io_register *reg = NULL; - - switch (set_iga) { - case IGA1: - reg_value = IGA1_FETCH_COUNT_FORMULA(h_addr, bpp_byte); - viafb_load_reg_num = fetch_count_reg. - iga1_fetch_count_reg.reg_num; - reg = fetch_count_reg.iga1_fetch_count_reg.reg; - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR); - break; - case IGA2: - reg_value = IGA2_FETCH_COUNT_FORMULA(h_addr, bpp_byte); - viafb_load_reg_num = fetch_count_reg. - iga2_fetch_count_reg.reg_num; - reg = fetch_count_reg.iga2_fetch_count_reg.reg; - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR); - break; - } - -} - -void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active) -{ - int reg_value; - int viafb_load_reg_num; - struct io_register *reg = NULL; - int iga1_fifo_max_depth = 0, iga1_fifo_threshold = - 0, iga1_fifo_high_threshold = 0, iga1_display_queue_expire_num = 0; - int iga2_fifo_max_depth = 0, iga2_fifo_threshold = - 0, iga2_fifo_high_threshold = 0, iga2_display_queue_expire_num = 0; - - if (set_iga == IGA1) { - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) { - iga1_fifo_max_depth = K800_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = K800_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - K800_IGA1_FIFO_HIGH_THRESHOLD; - /* If resolution > 1280x1024, expire length = 64, else - expire length = 128 */ - if ((hor_active > 1280) && (ver_active > 1024)) - iga1_display_queue_expire_num = 16; - else - iga1_display_queue_expire_num = - K800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_PM800) { - iga1_fifo_max_depth = P880_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = P880_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - P880_IGA1_FIFO_HIGH_THRESHOLD; - iga1_display_queue_expire_num = - P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - - /* If resolution > 1280x1024, expire length = 64, else - expire length = 128 */ - if ((hor_active > 1280) && (ver_active > 1024)) - iga1_display_queue_expire_num = 16; - else - iga1_display_queue_expire_num = - P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CN700) { - iga1_fifo_max_depth = CN700_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = CN700_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - CN700_IGA1_FIFO_HIGH_THRESHOLD; - - /* If resolution > 1280x1024, expire length = 64, - else expire length = 128 */ - if ((hor_active > 1280) && (ver_active > 1024)) - iga1_display_queue_expire_num = 16; - else - iga1_display_queue_expire_num = - CN700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) { - iga1_fifo_max_depth = CX700_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = CX700_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - CX700_IGA1_FIFO_HIGH_THRESHOLD; - iga1_display_queue_expire_num = - CX700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K8M890) { - iga1_fifo_max_depth = K8M890_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = K8M890_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - K8M890_IGA1_FIFO_HIGH_THRESHOLD; - iga1_display_queue_expire_num = - K8M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_P4M890) { - iga1_fifo_max_depth = P4M890_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = P4M890_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - P4M890_IGA1_FIFO_HIGH_THRESHOLD; - iga1_display_queue_expire_num = - P4M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_P4M900) { - iga1_fifo_max_depth = P4M900_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = P4M900_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - P4M900_IGA1_FIFO_HIGH_THRESHOLD; - iga1_display_queue_expire_num = - P4M900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_VX800) { - iga1_fifo_max_depth = VX800_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = VX800_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - VX800_IGA1_FIFO_HIGH_THRESHOLD; - iga1_display_queue_expire_num = - VX800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_VX855) { - iga1_fifo_max_depth = VX855_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = VX855_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - VX855_IGA1_FIFO_HIGH_THRESHOLD; - iga1_display_queue_expire_num = - VX855_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_VX900) { - iga1_fifo_max_depth = VX900_IGA1_FIFO_MAX_DEPTH; - iga1_fifo_threshold = VX900_IGA1_FIFO_THRESHOLD; - iga1_fifo_high_threshold = - VX900_IGA1_FIFO_HIGH_THRESHOLD; - iga1_display_queue_expire_num = - VX900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM; - } - - /* Set Display FIFO Depath Select */ - reg_value = IGA1_FIFO_DEPTH_SELECT_FORMULA(iga1_fifo_max_depth); - viafb_load_reg_num = - display_fifo_depth_reg.iga1_fifo_depth_select_reg.reg_num; - reg = display_fifo_depth_reg.iga1_fifo_depth_select_reg.reg; - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR); - - /* Set Display FIFO Threshold Select */ - reg_value = IGA1_FIFO_THRESHOLD_FORMULA(iga1_fifo_threshold); - viafb_load_reg_num = - fifo_threshold_select_reg. - iga1_fifo_threshold_select_reg.reg_num; - reg = - fifo_threshold_select_reg. - iga1_fifo_threshold_select_reg.reg; - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR); - - /* Set FIFO High Threshold Select */ - reg_value = - IGA1_FIFO_HIGH_THRESHOLD_FORMULA(iga1_fifo_high_threshold); - viafb_load_reg_num = - fifo_high_threshold_select_reg. - iga1_fifo_high_threshold_select_reg.reg_num; - reg = - fifo_high_threshold_select_reg. - iga1_fifo_high_threshold_select_reg.reg; - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR); - - /* Set Display Queue Expire Num */ - reg_value = - IGA1_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA - (iga1_display_queue_expire_num); - viafb_load_reg_num = - display_queue_expire_num_reg. - iga1_display_queue_expire_num_reg.reg_num; - reg = - display_queue_expire_num_reg. - iga1_display_queue_expire_num_reg.reg; - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIASR); - - } else { - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) { - iga2_fifo_max_depth = K800_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = K800_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - K800_IGA2_FIFO_HIGH_THRESHOLD; - - /* If resolution > 1280x1024, expire length = 64, - else expire length = 128 */ - if ((hor_active > 1280) && (ver_active > 1024)) - iga2_display_queue_expire_num = 16; - else - iga2_display_queue_expire_num = - K800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_PM800) { - iga2_fifo_max_depth = P880_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = P880_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - P880_IGA2_FIFO_HIGH_THRESHOLD; - - /* If resolution > 1280x1024, expire length = 64, - else expire length = 128 */ - if ((hor_active > 1280) && (ver_active > 1024)) - iga2_display_queue_expire_num = 16; - else - iga2_display_queue_expire_num = - P880_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CN700) { - iga2_fifo_max_depth = CN700_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = CN700_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - CN700_IGA2_FIFO_HIGH_THRESHOLD; - - /* If resolution > 1280x1024, expire length = 64, - else expire length = 128 */ - if ((hor_active > 1280) && (ver_active > 1024)) - iga2_display_queue_expire_num = 16; - else - iga2_display_queue_expire_num = - CN700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) { - iga2_fifo_max_depth = CX700_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = CX700_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - CX700_IGA2_FIFO_HIGH_THRESHOLD; - iga2_display_queue_expire_num = - CX700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K8M890) { - iga2_fifo_max_depth = K8M890_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = K8M890_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - K8M890_IGA2_FIFO_HIGH_THRESHOLD; - iga2_display_queue_expire_num = - K8M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_P4M890) { - iga2_fifo_max_depth = P4M890_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = P4M890_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - P4M890_IGA2_FIFO_HIGH_THRESHOLD; - iga2_display_queue_expire_num = - P4M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_P4M900) { - iga2_fifo_max_depth = P4M900_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = P4M900_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - P4M900_IGA2_FIFO_HIGH_THRESHOLD; - iga2_display_queue_expire_num = - P4M900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_VX800) { - iga2_fifo_max_depth = VX800_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = VX800_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - VX800_IGA2_FIFO_HIGH_THRESHOLD; - iga2_display_queue_expire_num = - VX800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_VX855) { - iga2_fifo_max_depth = VX855_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = VX855_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - VX855_IGA2_FIFO_HIGH_THRESHOLD; - iga2_display_queue_expire_num = - VX855_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_VX900) { - iga2_fifo_max_depth = VX900_IGA2_FIFO_MAX_DEPTH; - iga2_fifo_threshold = VX900_IGA2_FIFO_THRESHOLD; - iga2_fifo_high_threshold = - VX900_IGA2_FIFO_HIGH_THRESHOLD; - iga2_display_queue_expire_num = - VX900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM; - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) { - /* Set Display FIFO Depath Select */ - reg_value = - IGA2_FIFO_DEPTH_SELECT_FORMULA(iga2_fifo_max_depth) - - 1; - /* Patch LCD in IGA2 case */ - viafb_load_reg_num = - display_fifo_depth_reg. - iga2_fifo_depth_select_reg.reg_num; - reg = - display_fifo_depth_reg. - iga2_fifo_depth_select_reg.reg; - viafb_load_reg(reg_value, - viafb_load_reg_num, reg, VIACR); - } else { - - /* Set Display FIFO Depath Select */ - reg_value = - IGA2_FIFO_DEPTH_SELECT_FORMULA(iga2_fifo_max_depth); - viafb_load_reg_num = - display_fifo_depth_reg. - iga2_fifo_depth_select_reg.reg_num; - reg = - display_fifo_depth_reg. - iga2_fifo_depth_select_reg.reg; - viafb_load_reg(reg_value, - viafb_load_reg_num, reg, VIACR); - } - - /* Set Display FIFO Threshold Select */ - reg_value = IGA2_FIFO_THRESHOLD_FORMULA(iga2_fifo_threshold); - viafb_load_reg_num = - fifo_threshold_select_reg. - iga2_fifo_threshold_select_reg.reg_num; - reg = - fifo_threshold_select_reg. - iga2_fifo_threshold_select_reg.reg; - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR); - - /* Set FIFO High Threshold Select */ - reg_value = - IGA2_FIFO_HIGH_THRESHOLD_FORMULA(iga2_fifo_high_threshold); - viafb_load_reg_num = - fifo_high_threshold_select_reg. - iga2_fifo_high_threshold_select_reg.reg_num; - reg = - fifo_high_threshold_select_reg. - iga2_fifo_high_threshold_select_reg.reg; - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR); - - /* Set Display Queue Expire Num */ - reg_value = - IGA2_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA - (iga2_display_queue_expire_num); - viafb_load_reg_num = - display_queue_expire_num_reg. - iga2_display_queue_expire_num_reg.reg_num; - reg = - display_queue_expire_num_reg. - iga2_display_queue_expire_num_reg.reg; - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR); - - } - -} - -static u32 cle266_encode_pll(struct pll_config pll) -{ - return (pll.multiplier << 8) - | (pll.rshift << 6) - | pll.divisor; -} - -static u32 k800_encode_pll(struct pll_config pll) -{ - return ((pll.divisor - 2) << 16) - | (pll.rshift << 10) - | (pll.multiplier - 2); -} - -static u32 vx855_encode_pll(struct pll_config pll) -{ - return (pll.divisor << 16) - | (pll.rshift << 10) - | pll.multiplier; -} - -u32 viafb_get_clk_value(int clk) -{ - u32 value = 0; - int i = 0; - - while (i < NUM_TOTAL_PLL_TABLE && clk != pll_value[i].clk) - i++; - - if (i == NUM_TOTAL_PLL_TABLE) { - printk(KERN_WARNING "viafb_get_clk_value: PLL lookup failed!"); - } else { - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CLE266: - case UNICHROME_K400: - value = cle266_encode_pll(pll_value[i].cle266_pll); - break; - - case UNICHROME_K800: - case UNICHROME_PM800: - case UNICHROME_CN700: - value = k800_encode_pll(pll_value[i].k800_pll); - break; - - case UNICHROME_CX700: - case UNICHROME_CN750: - case UNICHROME_K8M890: - case UNICHROME_P4M890: - case UNICHROME_P4M900: - case UNICHROME_VX800: - value = k800_encode_pll(pll_value[i].cx700_pll); - break; - - case UNICHROME_VX855: - case UNICHROME_VX900: - value = vx855_encode_pll(pll_value[i].vx855_pll); - break; - } - } - - return value; -} - -/* Set VCLK*/ -void viafb_set_vclock(u32 clk, int set_iga) -{ - /* H.W. Reset : ON */ - viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); - - if (set_iga == IGA1) { - /* Change D,N FOR VCLK */ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CLE266: - case UNICHROME_K400: - via_write_reg(VIASR, SR46, (clk & 0x00FF)); - via_write_reg(VIASR, SR47, (clk & 0xFF00) >> 8); - break; - - case UNICHROME_K800: - case UNICHROME_PM800: - case UNICHROME_CN700: - case UNICHROME_CX700: - case UNICHROME_CN750: - case UNICHROME_K8M890: - case UNICHROME_P4M890: - case UNICHROME_P4M900: - case UNICHROME_VX800: - case UNICHROME_VX855: - case UNICHROME_VX900: - via_write_reg(VIASR, SR44, (clk & 0x0000FF)); - via_write_reg(VIASR, SR45, (clk & 0x00FF00) >> 8); - via_write_reg(VIASR, SR46, (clk & 0xFF0000) >> 16); - break; - } - } - - if (set_iga == IGA2) { - /* Change D,N FOR LCK */ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CLE266: - case UNICHROME_K400: - via_write_reg(VIASR, SR44, (clk & 0x00FF)); - via_write_reg(VIASR, SR45, (clk & 0xFF00) >> 8); - break; - - case UNICHROME_K800: - case UNICHROME_PM800: - case UNICHROME_CN700: - case UNICHROME_CX700: - case UNICHROME_CN750: - case UNICHROME_K8M890: - case UNICHROME_P4M890: - case UNICHROME_P4M900: - case UNICHROME_VX800: - case UNICHROME_VX855: - case UNICHROME_VX900: - via_write_reg(VIASR, SR4A, (clk & 0x0000FF)); - via_write_reg(VIASR, SR4B, (clk & 0x00FF00) >> 8); - via_write_reg(VIASR, SR4C, (clk & 0xFF0000) >> 16); - break; - } - } - - /* H.W. Reset : OFF */ - viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); - - /* Reset PLL */ - if (set_iga == IGA1) { - viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1); - viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1); - } - - if (set_iga == IGA2) { - viafb_write_reg_mask(SR40, VIASR, 0x04, BIT2); - viafb_write_reg_mask(SR40, VIASR, 0x00, BIT2); - } - - /* Fire! */ - via_write_misc_reg_mask(0x0C, 0x0C); /* select external clock */ -} - -void viafb_load_crtc_timing(struct display_timing device_timing, - int set_iga) -{ - int i; - int viafb_load_reg_num = 0; - int reg_value = 0; - struct io_register *reg = NULL; - - viafb_unlock_crt(); - - for (i = 0; i < 12; i++) { - if (set_iga == IGA1) { - switch (i) { - case H_TOTAL_INDEX: - reg_value = - IGA1_HOR_TOTAL_FORMULA(device_timing. - hor_total); - viafb_load_reg_num = - iga1_crtc_reg.hor_total.reg_num; - reg = iga1_crtc_reg.hor_total.reg; - break; - case H_ADDR_INDEX: - reg_value = - IGA1_HOR_ADDR_FORMULA(device_timing. - hor_addr); - viafb_load_reg_num = - iga1_crtc_reg.hor_addr.reg_num; - reg = iga1_crtc_reg.hor_addr.reg; - break; - case H_BLANK_START_INDEX: - reg_value = - IGA1_HOR_BLANK_START_FORMULA - (device_timing.hor_blank_start); - viafb_load_reg_num = - iga1_crtc_reg.hor_blank_start.reg_num; - reg = iga1_crtc_reg.hor_blank_start.reg; - break; - case H_BLANK_END_INDEX: - reg_value = - IGA1_HOR_BLANK_END_FORMULA - (device_timing.hor_blank_start, - device_timing.hor_blank_end); - viafb_load_reg_num = - iga1_crtc_reg.hor_blank_end.reg_num; - reg = iga1_crtc_reg.hor_blank_end.reg; - break; - case H_SYNC_START_INDEX: - reg_value = - IGA1_HOR_SYNC_START_FORMULA - (device_timing.hor_sync_start); - viafb_load_reg_num = - iga1_crtc_reg.hor_sync_start.reg_num; - reg = iga1_crtc_reg.hor_sync_start.reg; - break; - case H_SYNC_END_INDEX: - reg_value = - IGA1_HOR_SYNC_END_FORMULA - (device_timing.hor_sync_start, - device_timing.hor_sync_end); - viafb_load_reg_num = - iga1_crtc_reg.hor_sync_end.reg_num; - reg = iga1_crtc_reg.hor_sync_end.reg; - break; - case V_TOTAL_INDEX: - reg_value = - IGA1_VER_TOTAL_FORMULA(device_timing. - ver_total); - viafb_load_reg_num = - iga1_crtc_reg.ver_total.reg_num; - reg = iga1_crtc_reg.ver_total.reg; - break; - case V_ADDR_INDEX: - reg_value = - IGA1_VER_ADDR_FORMULA(device_timing. - ver_addr); - viafb_load_reg_num = - iga1_crtc_reg.ver_addr.reg_num; - reg = iga1_crtc_reg.ver_addr.reg; - break; - case V_BLANK_START_INDEX: - reg_value = - IGA1_VER_BLANK_START_FORMULA - (device_timing.ver_blank_start); - viafb_load_reg_num = - iga1_crtc_reg.ver_blank_start.reg_num; - reg = iga1_crtc_reg.ver_blank_start.reg; - break; - case V_BLANK_END_INDEX: - reg_value = - IGA1_VER_BLANK_END_FORMULA - (device_timing.ver_blank_start, - device_timing.ver_blank_end); - viafb_load_reg_num = - iga1_crtc_reg.ver_blank_end.reg_num; - reg = iga1_crtc_reg.ver_blank_end.reg; - break; - case V_SYNC_START_INDEX: - reg_value = - IGA1_VER_SYNC_START_FORMULA - (device_timing.ver_sync_start); - viafb_load_reg_num = - iga1_crtc_reg.ver_sync_start.reg_num; - reg = iga1_crtc_reg.ver_sync_start.reg; - break; - case V_SYNC_END_INDEX: - reg_value = - IGA1_VER_SYNC_END_FORMULA - (device_timing.ver_sync_start, - device_timing.ver_sync_end); - viafb_load_reg_num = - iga1_crtc_reg.ver_sync_end.reg_num; - reg = iga1_crtc_reg.ver_sync_end.reg; - break; - - } - } - - if (set_iga == IGA2) { - switch (i) { - case H_TOTAL_INDEX: - reg_value = - IGA2_HOR_TOTAL_FORMULA(device_timing. - hor_total); - viafb_load_reg_num = - iga2_crtc_reg.hor_total.reg_num; - reg = iga2_crtc_reg.hor_total.reg; - break; - case H_ADDR_INDEX: - reg_value = - IGA2_HOR_ADDR_FORMULA(device_timing. - hor_addr); - viafb_load_reg_num = - iga2_crtc_reg.hor_addr.reg_num; - reg = iga2_crtc_reg.hor_addr.reg; - break; - case H_BLANK_START_INDEX: - reg_value = - IGA2_HOR_BLANK_START_FORMULA - (device_timing.hor_blank_start); - viafb_load_reg_num = - iga2_crtc_reg.hor_blank_start.reg_num; - reg = iga2_crtc_reg.hor_blank_start.reg; - break; - case H_BLANK_END_INDEX: - reg_value = - IGA2_HOR_BLANK_END_FORMULA - (device_timing.hor_blank_start, - device_timing.hor_blank_end); - viafb_load_reg_num = - iga2_crtc_reg.hor_blank_end.reg_num; - reg = iga2_crtc_reg.hor_blank_end.reg; - break; - case H_SYNC_START_INDEX: - reg_value = - IGA2_HOR_SYNC_START_FORMULA - (device_timing.hor_sync_start); - if (UNICHROME_CN700 <= - viaparinfo->chip_info->gfx_chip_name) - viafb_load_reg_num = - iga2_crtc_reg.hor_sync_start. - reg_num; - else - viafb_load_reg_num = 3; - reg = iga2_crtc_reg.hor_sync_start.reg; - break; - case H_SYNC_END_INDEX: - reg_value = - IGA2_HOR_SYNC_END_FORMULA - (device_timing.hor_sync_start, - device_timing.hor_sync_end); - viafb_load_reg_num = - iga2_crtc_reg.hor_sync_end.reg_num; - reg = iga2_crtc_reg.hor_sync_end.reg; - break; - case V_TOTAL_INDEX: - reg_value = - IGA2_VER_TOTAL_FORMULA(device_timing. - ver_total); - viafb_load_reg_num = - iga2_crtc_reg.ver_total.reg_num; - reg = iga2_crtc_reg.ver_total.reg; - break; - case V_ADDR_INDEX: - reg_value = - IGA2_VER_ADDR_FORMULA(device_timing. - ver_addr); - viafb_load_reg_num = - iga2_crtc_reg.ver_addr.reg_num; - reg = iga2_crtc_reg.ver_addr.reg; - break; - case V_BLANK_START_INDEX: - reg_value = - IGA2_VER_BLANK_START_FORMULA - (device_timing.ver_blank_start); - viafb_load_reg_num = - iga2_crtc_reg.ver_blank_start.reg_num; - reg = iga2_crtc_reg.ver_blank_start.reg; - break; - case V_BLANK_END_INDEX: - reg_value = - IGA2_VER_BLANK_END_FORMULA - (device_timing.ver_blank_start, - device_timing.ver_blank_end); - viafb_load_reg_num = - iga2_crtc_reg.ver_blank_end.reg_num; - reg = iga2_crtc_reg.ver_blank_end.reg; - break; - case V_SYNC_START_INDEX: - reg_value = - IGA2_VER_SYNC_START_FORMULA - (device_timing.ver_sync_start); - viafb_load_reg_num = - iga2_crtc_reg.ver_sync_start.reg_num; - reg = iga2_crtc_reg.ver_sync_start.reg; - break; - case V_SYNC_END_INDEX: - reg_value = - IGA2_VER_SYNC_END_FORMULA - (device_timing.ver_sync_start, - device_timing.ver_sync_end); - viafb_load_reg_num = - iga2_crtc_reg.ver_sync_end.reg_num; - reg = iga2_crtc_reg.ver_sync_end.reg; - break; - - } - } - viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR); - } - - viafb_lock_crt(); -} - -void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, - struct VideoModeTable *video_mode, int bpp_byte, int set_iga) -{ - struct display_timing crt_reg; - int i; - int index = 0; - int h_addr, v_addr; - u32 pll_D_N; - - for (i = 0; i < video_mode->mode_array; i++) { - index = i; - - if (crt_table[i].refresh_rate == viaparinfo-> - crt_setting_info->refresh_rate) - break; - } - - crt_reg = crt_table[index].crtc; - - /* Mode 640x480 has border, but LCD/DFP didn't have border. */ - /* So we would delete border. */ - if ((viafb_LCD_ON | viafb_DVI_ON) - && video_mode->crtc[0].crtc.hor_addr == 640 - && video_mode->crtc[0].crtc.ver_addr == 480 - && viaparinfo->crt_setting_info->refresh_rate == 60) { - /* The border is 8 pixels. */ - crt_reg.hor_blank_start = crt_reg.hor_blank_start - 8; - - /* Blanking time should add left and right borders. */ - crt_reg.hor_blank_end = crt_reg.hor_blank_end + 16; - } - - h_addr = crt_reg.hor_addr; - v_addr = crt_reg.ver_addr; - if (set_iga == IGA1) { - viafb_unlock_crt(); - viafb_write_reg(CR09, VIACR, 0x00); /*initial CR09=0 */ - viafb_write_reg_mask(CR11, VIACR, 0x00, BIT4 + BIT5 + BIT6); - viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); - } - - switch (set_iga) { - case IGA1: - viafb_load_crtc_timing(crt_reg, IGA1); - break; - case IGA2: - viafb_load_crtc_timing(crt_reg, IGA2); - break; - } - - load_fix_bit_crtc_reg(); - viafb_lock_crt(); - viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); - viafb_load_fetch_count_reg(h_addr, bpp_byte, set_iga); - - /* load FIFO */ - if ((viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266) - && (viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400)) - viafb_load_FIFO_reg(set_iga, h_addr, v_addr); - - pll_D_N = viafb_get_clk_value(crt_table[index].clk); - DEBUG_MSG(KERN_INFO "PLL=%x", pll_D_N); - viafb_set_vclock(pll_D_N, set_iga); - -} - -void __devinit viafb_init_chip_info(int chip_type) -{ - init_gfx_chip_info(chip_type); - init_tmds_chip_info(); - init_lvds_chip_info(); - - viaparinfo->crt_setting_info->iga_path = IGA1; - viaparinfo->crt_setting_info->refresh_rate = viafb_refresh; - - /*Set IGA path for each device */ - viafb_set_iga_path(); - - viaparinfo->lvds_setting_info->display_method = viafb_lcd_dsp_method; - viaparinfo->lvds_setting_info->lcd_mode = viafb_lcd_mode; - viaparinfo->lvds_setting_info2->display_method = - viaparinfo->lvds_setting_info->display_method; - viaparinfo->lvds_setting_info2->lcd_mode = - viaparinfo->lvds_setting_info->lcd_mode; -} - -void viafb_update_device_setting(int hres, int vres, - int bpp, int vmode_refresh, int flag) -{ - if (flag == 0) { - viaparinfo->crt_setting_info->h_active = hres; - viaparinfo->crt_setting_info->v_active = vres; - viaparinfo->crt_setting_info->bpp = bpp; - viaparinfo->crt_setting_info->refresh_rate = - vmode_refresh; - - viaparinfo->tmds_setting_info->h_active = hres; - viaparinfo->tmds_setting_info->v_active = vres; - - viaparinfo->lvds_setting_info->h_active = hres; - viaparinfo->lvds_setting_info->v_active = vres; - viaparinfo->lvds_setting_info->bpp = bpp; - viaparinfo->lvds_setting_info->refresh_rate = - vmode_refresh; - viaparinfo->lvds_setting_info2->h_active = hres; - viaparinfo->lvds_setting_info2->v_active = vres; - viaparinfo->lvds_setting_info2->bpp = bpp; - viaparinfo->lvds_setting_info2->refresh_rate = - vmode_refresh; - } else { - - if (viaparinfo->tmds_setting_info->iga_path == IGA2) { - viaparinfo->tmds_setting_info->h_active = hres; - viaparinfo->tmds_setting_info->v_active = vres; - } - - if (viaparinfo->lvds_setting_info->iga_path == IGA2) { - viaparinfo->lvds_setting_info->h_active = hres; - viaparinfo->lvds_setting_info->v_active = vres; - viaparinfo->lvds_setting_info->bpp = bpp; - viaparinfo->lvds_setting_info->refresh_rate = - vmode_refresh; - } - if (IGA2 == viaparinfo->lvds_setting_info2->iga_path) { - viaparinfo->lvds_setting_info2->h_active = hres; - viaparinfo->lvds_setting_info2->v_active = vres; - viaparinfo->lvds_setting_info2->bpp = bpp; - viaparinfo->lvds_setting_info2->refresh_rate = - vmode_refresh; - } - } -} - -static void __devinit init_gfx_chip_info(int chip_type) -{ - u8 tmp; - - viaparinfo->chip_info->gfx_chip_name = chip_type; - - /* Check revision of CLE266 Chip */ - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { - /* CR4F only define in CLE266.CX chip */ - tmp = viafb_read_reg(VIACR, CR4F); - viafb_write_reg(CR4F, VIACR, 0x55); - if (viafb_read_reg(VIACR, CR4F) != 0x55) - viaparinfo->chip_info->gfx_chip_revision = - CLE266_REVISION_AX; - else - viaparinfo->chip_info->gfx_chip_revision = - CLE266_REVISION_CX; - /* restore orignal CR4F value */ - viafb_write_reg(CR4F, VIACR, tmp); - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) { - tmp = viafb_read_reg(VIASR, SR43); - DEBUG_MSG(KERN_INFO "SR43:%X\n", tmp); - if (tmp & 0x02) { - viaparinfo->chip_info->gfx_chip_revision = - CX700_REVISION_700M2; - } else if (tmp & 0x40) { - viaparinfo->chip_info->gfx_chip_revision = - CX700_REVISION_700M; - } else { - viaparinfo->chip_info->gfx_chip_revision = - CX700_REVISION_700; - } - } - - /* Determine which 2D engine we have */ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_VX800: - case UNICHROME_VX855: - case UNICHROME_VX900: - viaparinfo->chip_info->twod_engine = VIA_2D_ENG_M1; - break; - case UNICHROME_K8M890: - case UNICHROME_P4M900: - viaparinfo->chip_info->twod_engine = VIA_2D_ENG_H5; - break; - default: - viaparinfo->chip_info->twod_engine = VIA_2D_ENG_H2; - break; - } -} - -static void __devinit init_tmds_chip_info(void) -{ - viafb_tmds_trasmitter_identify(); - - if (INTERFACE_NONE == viaparinfo->chip_info->tmds_chip_info. - output_interface) { - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CX700: - { - /* we should check support by hardware layout.*/ - if ((viafb_display_hardware_layout == - HW_LAYOUT_DVI_ONLY) - || (viafb_display_hardware_layout == - HW_LAYOUT_LCD_DVI)) { - viaparinfo->chip_info->tmds_chip_info. - output_interface = INTERFACE_TMDS; - } else { - viaparinfo->chip_info->tmds_chip_info. - output_interface = - INTERFACE_NONE; - } - break; - } - case UNICHROME_K8M890: - case UNICHROME_P4M900: - case UNICHROME_P4M890: - /* TMDS on PCIE, we set DFPLOW as default. */ - viaparinfo->chip_info->tmds_chip_info.output_interface = - INTERFACE_DFP_LOW; - break; - default: - { - /* set DVP1 default for DVI */ - viaparinfo->chip_info->tmds_chip_info - .output_interface = INTERFACE_DVP1; - } - } - } - - DEBUG_MSG(KERN_INFO "TMDS Chip = %d\n", - viaparinfo->chip_info->tmds_chip_info.tmds_chip_name); - viafb_init_dvi_size(&viaparinfo->shared->chip_info.tmds_chip_info, - &viaparinfo->shared->tmds_setting_info); -} - -static void __devinit init_lvds_chip_info(void) -{ - viafb_lvds_trasmitter_identify(); - viafb_init_lcd_size(); - viafb_init_lvds_output_interface(&viaparinfo->chip_info->lvds_chip_info, - viaparinfo->lvds_setting_info); - if (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { - viafb_init_lvds_output_interface(&viaparinfo->chip_info-> - lvds_chip_info2, viaparinfo->lvds_setting_info2); - } - /*If CX700,two singel LCD, we need to reassign - LCD interface to different LVDS port */ - if ((UNICHROME_CX700 == viaparinfo->chip_info->gfx_chip_name) - && (HW_LAYOUT_LCD1_LCD2 == viafb_display_hardware_layout)) { - if ((INTEGRATED_LVDS == viaparinfo->chip_info->lvds_chip_info. - lvds_chip_name) && (INTEGRATED_LVDS == - viaparinfo->chip_info-> - lvds_chip_info2.lvds_chip_name)) { - viaparinfo->chip_info->lvds_chip_info.output_interface = - INTERFACE_LVDS0; - viaparinfo->chip_info->lvds_chip_info2. - output_interface = - INTERFACE_LVDS1; - } - } - - DEBUG_MSG(KERN_INFO "LVDS Chip = %d\n", - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name); - DEBUG_MSG(KERN_INFO "LVDS1 output_interface = %d\n", - viaparinfo->chip_info->lvds_chip_info.output_interface); - DEBUG_MSG(KERN_INFO "LVDS2 output_interface = %d\n", - viaparinfo->chip_info->lvds_chip_info.output_interface); -} - -void __devinit viafb_init_dac(int set_iga) -{ - int i; - u8 tmp; - - if (set_iga == IGA1) { - /* access Primary Display's LUT */ - viafb_write_reg_mask(SR1A, VIASR, 0x00, BIT0); - /* turn off LCK */ - viafb_write_reg_mask(SR1B, VIASR, 0x00, BIT7 + BIT6); - for (i = 0; i < 256; i++) { - write_dac_reg(i, palLUT_table[i].red, - palLUT_table[i].green, - palLUT_table[i].blue); - } - /* turn on LCK */ - viafb_write_reg_mask(SR1B, VIASR, 0xC0, BIT7 + BIT6); - } else { - tmp = viafb_read_reg(VIACR, CR6A); - /* access Secondary Display's LUT */ - viafb_write_reg_mask(CR6A, VIACR, 0x40, BIT6); - viafb_write_reg_mask(SR1A, VIASR, 0x01, BIT0); - for (i = 0; i < 256; i++) { - write_dac_reg(i, palLUT_table[i].red, - palLUT_table[i].green, - palLUT_table[i].blue); - } - /* set IGA1 DAC for default */ - viafb_write_reg_mask(SR1A, VIASR, 0x00, BIT0); - viafb_write_reg(CR6A, VIACR, tmp); - } -} - -static void device_screen_off(void) -{ - /* turn off CRT screen (IGA1) */ - viafb_write_reg_mask(SR01, VIASR, 0x20, BIT5); -} - -static void device_screen_on(void) -{ - /* turn on CRT screen (IGA1) */ - viafb_write_reg_mask(SR01, VIASR, 0x00, BIT5); -} - -static void set_display_channel(void) -{ - /*If viafb_LCD2_ON, on cx700, internal lvds's information - is keeped on lvds_setting_info2 */ - if (viafb_LCD2_ON && - viaparinfo->lvds_setting_info2->device_lcd_dualedge) { - /* For dual channel LCD: */ - /* Set to Dual LVDS channel. */ - viafb_write_reg_mask(CRD2, VIACR, 0x20, BIT4 + BIT5); - } else if (viafb_LCD_ON && viafb_DVI_ON) { - /* For LCD+DFP: */ - /* Set to LVDS1 + TMDS channel. */ - viafb_write_reg_mask(CRD2, VIACR, 0x10, BIT4 + BIT5); - } else if (viafb_DVI_ON) { - /* Set to single TMDS channel. */ - viafb_write_reg_mask(CRD2, VIACR, 0x30, BIT4 + BIT5); - } else if (viafb_LCD_ON) { - if (viaparinfo->lvds_setting_info->device_lcd_dualedge) { - /* For dual channel LCD: */ - /* Set to Dual LVDS channel. */ - viafb_write_reg_mask(CRD2, VIACR, 0x20, BIT4 + BIT5); - } else { - /* Set to LVDS0 + LVDS1 channel. */ - viafb_write_reg_mask(CRD2, VIACR, 0x00, BIT4 + BIT5); - } - } -} - -static u8 get_sync(struct fb_info *info) -{ - u8 polarity = 0; - - if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) - polarity |= VIA_HSYNC_NEGATIVE; - if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) - polarity |= VIA_VSYNC_NEGATIVE; - return polarity; -} - -int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp, - struct VideoModeTable *vmode_tbl1, int video_bpp1) -{ - int i, j; - int port; - u32 devices = viaparinfo->shared->iga1_devices - | viaparinfo->shared->iga2_devices; - u8 value, index, mask; - struct crt_mode_table *crt_timing; - struct crt_mode_table *crt_timing1 = NULL; - - device_screen_off(); - crt_timing = vmode_tbl->crtc; - - if (viafb_SAMM_ON == 1) { - crt_timing1 = vmode_tbl1->crtc; - } - - inb(VIAStatus); - outb(0x00, VIAAR); - - /* Write Common Setting for Video Mode */ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CLE266: - viafb_write_regx(CLE266_ModeXregs, NUM_TOTAL_CLE266_ModeXregs); - break; - - case UNICHROME_K400: - viafb_write_regx(KM400_ModeXregs, NUM_TOTAL_KM400_ModeXregs); - break; - - case UNICHROME_K800: - case UNICHROME_PM800: - viafb_write_regx(CN400_ModeXregs, NUM_TOTAL_CN400_ModeXregs); - break; - - case UNICHROME_CN700: - case UNICHROME_K8M890: - case UNICHROME_P4M890: - case UNICHROME_P4M900: - viafb_write_regx(CN700_ModeXregs, NUM_TOTAL_CN700_ModeXregs); - break; - - case UNICHROME_CX700: - case UNICHROME_VX800: - viafb_write_regx(CX700_ModeXregs, NUM_TOTAL_CX700_ModeXregs); - break; - - case UNICHROME_VX855: - case UNICHROME_VX900: - viafb_write_regx(VX855_ModeXregs, NUM_TOTAL_VX855_ModeXregs); - break; - } - - device_off(); - via_set_state(devices, VIA_STATE_OFF); - - /* Fill VPIT Parameters */ - /* Write Misc Register */ - outb(VPIT.Misc, VIA_MISC_REG_WRITE); - - /* Write Sequencer */ - for (i = 1; i <= StdSR; i++) - via_write_reg(VIASR, i, VPIT.SR[i - 1]); - - viafb_write_reg_mask(0x15, VIASR, 0xA2, 0xA2); - - /* Write CRTC */ - viafb_fill_crtc_timing(crt_timing, vmode_tbl, video_bpp / 8, IGA1); - - /* Write Graphic Controller */ - for (i = 0; i < StdGR; i++) - via_write_reg(VIAGR, i, VPIT.GR[i]); - - /* Write Attribute Controller */ - for (i = 0; i < StdAR; i++) { - inb(VIAStatus); - outb(i, VIAAR); - outb(VPIT.AR[i], VIAAR); - } - - inb(VIAStatus); - outb(0x20, VIAAR); - - /* Update Patch Register */ - - if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266 - || viaparinfo->chip_info->gfx_chip_name == UNICHROME_K400) - && vmode_tbl->crtc[0].crtc.hor_addr == 1024 - && vmode_tbl->crtc[0].crtc.ver_addr == 768) { - for (j = 0; j < res_patch_table[0].table_length; j++) { - index = res_patch_table[0].io_reg_table[j].index; - port = res_patch_table[0].io_reg_table[j].port; - value = res_patch_table[0].io_reg_table[j].value; - mask = res_patch_table[0].io_reg_table[j].mask; - viafb_write_reg_mask(index, port, value, mask); - } - } - - via_set_primary_pitch(viafbinfo->fix.line_length); - via_set_secondary_pitch(viafb_dual_fb ? viafbinfo1->fix.line_length - : viafbinfo->fix.line_length); - via_set_primary_color_depth(viaparinfo->depth); - via_set_secondary_color_depth(viafb_dual_fb ? viaparinfo1->depth - : viaparinfo->depth); - via_set_source(viaparinfo->shared->iga1_devices, IGA1); - via_set_source(viaparinfo->shared->iga2_devices, IGA2); - if (viaparinfo->shared->iga2_devices) - enable_second_display_channel(); - else - disable_second_display_channel(); - - /* Update Refresh Rate Setting */ - - /* Clear On Screen */ - - /* CRT set mode */ - if (viafb_CRT_ON) { - if (viafb_SAMM_ON && (viaparinfo->crt_setting_info->iga_path == - IGA2)) { - viafb_fill_crtc_timing(crt_timing1, vmode_tbl1, - video_bpp1 / 8, - viaparinfo->crt_setting_info->iga_path); - } else { - viafb_fill_crtc_timing(crt_timing, vmode_tbl, - video_bpp / 8, - viaparinfo->crt_setting_info->iga_path); - } - - /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode - to 8 alignment (1368),there is several pixels (2 pixels) - on right side of screen. */ - if (vmode_tbl->crtc[0].crtc.hor_addr % 8) { - viafb_unlock_crt(); - viafb_write_reg(CR02, VIACR, - viafb_read_reg(VIACR, CR02) - 1); - viafb_lock_crt(); - } - } - - if (viafb_DVI_ON) { - if (viafb_SAMM_ON && - (viaparinfo->tmds_setting_info->iga_path == IGA2)) { - viafb_dvi_set_mode(viafb_get_mode - (viaparinfo->tmds_setting_info->h_active, - viaparinfo->tmds_setting_info-> - v_active), - video_bpp1, viaparinfo-> - tmds_setting_info->iga_path); - } else { - viafb_dvi_set_mode(viafb_get_mode - (viaparinfo->tmds_setting_info->h_active, - viaparinfo-> - tmds_setting_info->v_active), - video_bpp, viaparinfo-> - tmds_setting_info->iga_path); - } - } - - if (viafb_LCD_ON) { - if (viafb_SAMM_ON && - (viaparinfo->lvds_setting_info->iga_path == IGA2)) { - viaparinfo->lvds_setting_info->bpp = video_bpp1; - viafb_lcd_set_mode(crt_timing1, viaparinfo-> - lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info); - } else { - /* IGA1 doesn't have LCD scaling, so set it center. */ - if (viaparinfo->lvds_setting_info->iga_path == IGA1) { - viaparinfo->lvds_setting_info->display_method = - LCD_CENTERING; - } - viaparinfo->lvds_setting_info->bpp = video_bpp; - viafb_lcd_set_mode(crt_timing, viaparinfo-> - lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info); - } - } - if (viafb_LCD2_ON) { - if (viafb_SAMM_ON && - (viaparinfo->lvds_setting_info2->iga_path == IGA2)) { - viaparinfo->lvds_setting_info2->bpp = video_bpp1; - viafb_lcd_set_mode(crt_timing1, viaparinfo-> - lvds_setting_info2, - &viaparinfo->chip_info->lvds_chip_info2); - } else { - /* IGA1 doesn't have LCD scaling, so set it center. */ - if (viaparinfo->lvds_setting_info2->iga_path == IGA1) { - viaparinfo->lvds_setting_info2->display_method = - LCD_CENTERING; - } - viaparinfo->lvds_setting_info2->bpp = video_bpp; - viafb_lcd_set_mode(crt_timing, viaparinfo-> - lvds_setting_info2, - &viaparinfo->chip_info->lvds_chip_info2); - } - } - - if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) - && (viafb_LCD_ON || viafb_DVI_ON)) - set_display_channel(); - - /* If set mode normally, save resolution information for hot-plug . */ - if (!viafb_hotplug) { - viafb_hotplug_Xres = vmode_tbl->crtc[0].crtc.hor_addr; - viafb_hotplug_Yres = vmode_tbl->crtc[0].crtc.ver_addr; - viafb_hotplug_bpp = video_bpp; - viafb_hotplug_refresh = viafb_refresh; - - if (viafb_DVI_ON) - viafb_DeviceStatus = DVI_Device; - else - viafb_DeviceStatus = CRT_Device; - } - device_on(); - if (!viafb_dual_fb) - via_set_sync_polarity(devices, get_sync(viafbinfo)); - else { - via_set_sync_polarity(viaparinfo->shared->iga1_devices, - get_sync(viafbinfo)); - via_set_sync_polarity(viaparinfo->shared->iga2_devices, - get_sync(viafbinfo1)); - } - - via_set_state(devices, VIA_STATE_ON); - device_screen_on(); - return 1; -} - -int viafb_get_pixclock(int hres, int vres, int vmode_refresh) -{ - int i; - - for (i = 0; i < NUM_TOTAL_RES_MAP_REFRESH; i++) { - if ((hres == res_map_refresh_tbl[i].hres) - && (vres == res_map_refresh_tbl[i].vres) - && (vmode_refresh == res_map_refresh_tbl[i].vmode_refresh)) - return res_map_refresh_tbl[i].pixclock; - } - return RES_640X480_60HZ_PIXCLOCK; - -} - -int viafb_get_refresh(int hres, int vres, u32 long_refresh) -{ -#define REFRESH_TOLERANCE 3 - int i, nearest = -1, diff = REFRESH_TOLERANCE; - for (i = 0; i < NUM_TOTAL_RES_MAP_REFRESH; i++) { - if ((hres == res_map_refresh_tbl[i].hres) - && (vres == res_map_refresh_tbl[i].vres) - && (diff > (abs(long_refresh - - res_map_refresh_tbl[i].vmode_refresh)))) { - diff = abs(long_refresh - res_map_refresh_tbl[i]. - vmode_refresh); - nearest = i; - } - } -#undef REFRESH_TOLERANCE - if (nearest > 0) - return res_map_refresh_tbl[nearest].vmode_refresh; - return 60; -} - -static void device_off(void) -{ - viafb_dvi_disable(); - viafb_lcd_disable(); -} - -static void device_on(void) -{ - if (viafb_DVI_ON == 1) - viafb_dvi_enable(); - if (viafb_LCD_ON == 1) - viafb_lcd_enable(); -} - -static void enable_second_display_channel(void) -{ - /* to enable second display channel. */ - viafb_write_reg_mask(CR6A, VIACR, 0x00, BIT6); - viafb_write_reg_mask(CR6A, VIACR, BIT7, BIT7); - viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6); -} - -static void disable_second_display_channel(void) -{ - /* to disable second display channel. */ - viafb_write_reg_mask(CR6A, VIACR, 0x00, BIT6); - viafb_write_reg_mask(CR6A, VIACR, 0x00, BIT7); - viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6); -} - -void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ - *p_gfx_dpa_setting) -{ - switch (output_interface) { - case INTERFACE_DVP0: - { - /* DVP0 Clock Polarity and Adjust: */ - viafb_write_reg_mask(CR96, VIACR, - p_gfx_dpa_setting->DVP0, 0x0F); - - /* DVP0 Clock and Data Pads Driving: */ - viafb_write_reg_mask(SR1E, VIASR, - p_gfx_dpa_setting->DVP0ClockDri_S, BIT2); - viafb_write_reg_mask(SR2A, VIASR, - p_gfx_dpa_setting->DVP0ClockDri_S1, - BIT4); - viafb_write_reg_mask(SR1B, VIASR, - p_gfx_dpa_setting->DVP0DataDri_S, BIT1); - viafb_write_reg_mask(SR2A, VIASR, - p_gfx_dpa_setting->DVP0DataDri_S1, BIT5); - break; - } - - case INTERFACE_DVP1: - { - /* DVP1 Clock Polarity and Adjust: */ - viafb_write_reg_mask(CR9B, VIACR, - p_gfx_dpa_setting->DVP1, 0x0F); - - /* DVP1 Clock and Data Pads Driving: */ - viafb_write_reg_mask(SR65, VIASR, - p_gfx_dpa_setting->DVP1Driving, 0x0F); - break; - } - - case INTERFACE_DFP_HIGH: - { - viafb_write_reg_mask(CR97, VIACR, - p_gfx_dpa_setting->DFPHigh, 0x0F); - break; - } - - case INTERFACE_DFP_LOW: - { - viafb_write_reg_mask(CR99, VIACR, - p_gfx_dpa_setting->DFPLow, 0x0F); - break; - } - - case INTERFACE_DFP: - { - viafb_write_reg_mask(CR97, VIACR, - p_gfx_dpa_setting->DFPHigh, 0x0F); - viafb_write_reg_mask(CR99, VIACR, - p_gfx_dpa_setting->DFPLow, 0x0F); - break; - } - } -} - -/*According var's xres, yres fill var's other timing information*/ -void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, - struct VideoModeTable *vmode_tbl) -{ - struct crt_mode_table *crt_timing = NULL; - struct display_timing crt_reg; - int i = 0, index = 0; - crt_timing = vmode_tbl->crtc; - for (i = 0; i < vmode_tbl->mode_array; i++) { - index = i; - if (crt_timing[i].refresh_rate == refresh) - break; - } - - crt_reg = crt_timing[index].crtc; - var->pixclock = viafb_get_pixclock(var->xres, var->yres, refresh); - var->left_margin = - crt_reg.hor_total - (crt_reg.hor_sync_start + crt_reg.hor_sync_end); - var->right_margin = crt_reg.hor_sync_start - crt_reg.hor_addr; - var->hsync_len = crt_reg.hor_sync_end; - var->upper_margin = - crt_reg.ver_total - (crt_reg.ver_sync_start + crt_reg.ver_sync_end); - var->lower_margin = crt_reg.ver_sync_start - crt_reg.ver_addr; - var->vsync_len = crt_reg.ver_sync_end; - var->sync = 0; - if (crt_timing[index].h_sync_polarity == POSITIVE) - var->sync |= FB_SYNC_HOR_HIGH_ACT; - if (crt_timing[index].v_sync_polarity == POSITIVE) - var->sync |= FB_SYNC_VERT_HIGH_ACT; -} diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h deleted file mode 100644 index 668d534542e..00000000000 --- a/drivers/video/via/hw.h +++ /dev/null @@ -1,962 +0,0 @@ -/* - * 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 __HW_H__ -#define __HW_H__ - -#include <linux/seq_file.h> - -#include "viamode.h" -#include "global.h" -#include "via_modesetting.h" - -#define viafb_read_reg(p, i) via_read_reg(p, i) -#define viafb_write_reg(i, p, d) via_write_reg(p, i, d) -#define viafb_write_reg_mask(i, p, d, m) via_write_reg_mask(p, i, d, m) - -/* VIA output devices */ -#define VIA_LDVP0 0x00000001 -#define VIA_LDVP1 0x00000002 -#define VIA_DVP0 0x00000004 -#define VIA_CRT 0x00000010 -#define VIA_DVP1 0x00000020 -#define VIA_LVDS1 0x00000040 -#define VIA_LVDS2 0x00000080 - -/* VIA output device power states */ -#define VIA_STATE_ON 0 -#define VIA_STATE_STANDBY 1 -#define VIA_STATE_SUSPEND 2 -#define VIA_STATE_OFF 3 - -/* VIA output device sync polarity */ -#define VIA_HSYNC_NEGATIVE 0x01 -#define VIA_VSYNC_NEGATIVE 0x02 - -/*************************************************** -* Definition IGA1 Design Method of CRTC Registers * -****************************************************/ -#define IGA1_HOR_TOTAL_FORMULA(x) (((x)/8)-5) -#define IGA1_HOR_ADDR_FORMULA(x) (((x)/8)-1) -#define IGA1_HOR_BLANK_START_FORMULA(x) (((x)/8)-1) -#define IGA1_HOR_BLANK_END_FORMULA(x, y) (((x+y)/8)-1) -#define IGA1_HOR_SYNC_START_FORMULA(x) ((x)/8) -#define IGA1_HOR_SYNC_END_FORMULA(x, y) ((x+y)/8) - -#define IGA1_VER_TOTAL_FORMULA(x) ((x)-2) -#define IGA1_VER_ADDR_FORMULA(x) ((x)-1) -#define IGA1_VER_BLANK_START_FORMULA(x) ((x)-1) -#define IGA1_VER_BLANK_END_FORMULA(x, y) ((x+y)-1) -#define IGA1_VER_SYNC_START_FORMULA(x) ((x)-1) -#define IGA1_VER_SYNC_END_FORMULA(x, y) ((x+y)-1) - -/*************************************************** -** Definition IGA2 Design Method of CRTC Registers * -****************************************************/ -#define IGA2_HOR_TOTAL_FORMULA(x) ((x)-1) -#define IGA2_HOR_ADDR_FORMULA(x) ((x)-1) -#define IGA2_HOR_BLANK_START_FORMULA(x) ((x)-1) -#define IGA2_HOR_BLANK_END_FORMULA(x, y) ((x+y)-1) -#define IGA2_HOR_SYNC_START_FORMULA(x) ((x)-1) -#define IGA2_HOR_SYNC_END_FORMULA(x, y) ((x+y)-1) - -#define IGA2_VER_TOTAL_FORMULA(x) ((x)-1) -#define IGA2_VER_ADDR_FORMULA(x) ((x)-1) -#define IGA2_VER_BLANK_START_FORMULA(x) ((x)-1) -#define IGA2_VER_BLANK_END_FORMULA(x, y) ((x+y)-1) -#define IGA2_VER_SYNC_START_FORMULA(x) ((x)-1) -#define IGA2_VER_SYNC_END_FORMULA(x, y) ((x+y)-1) - -/**********************************************************/ -/* Definition IGA2 Design Method of CRTC Shadow Registers */ -/**********************************************************/ -#define IGA2_HOR_TOTAL_SHADOW_FORMULA(x) ((x/8)-5) -#define IGA2_HOR_BLANK_END_SHADOW_FORMULA(x, y) (((x+y)/8)-1) -#define IGA2_VER_TOTAL_SHADOW_FORMULA(x) ((x)-2) -#define IGA2_VER_ADDR_SHADOW_FORMULA(x) ((x)-1) -#define IGA2_VER_BLANK_START_SHADOW_FORMULA(x) ((x)-1) -#define IGA2_VER_BLANK_END_SHADOW_FORMULA(x, y) ((x+y)-1) -#define IGA2_VER_SYNC_START_SHADOW_FORMULA(x) (x) -#define IGA2_VER_SYNC_END_SHADOW_FORMULA(x, y) (x+y) - -/* Define Register Number for IGA1 CRTC Timing */ - -/* location: {CR00,0,7},{CR36,3,3} */ -#define IGA1_HOR_TOTAL_REG_NUM 2 -/* location: {CR01,0,7} */ -#define IGA1_HOR_ADDR_REG_NUM 1 -/* location: {CR02,0,7} */ -#define IGA1_HOR_BLANK_START_REG_NUM 1 -/* location: {CR03,0,4},{CR05,7,7},{CR33,5,5} */ -#define IGA1_HOR_BLANK_END_REG_NUM 3 -/* location: {CR04,0,7},{CR33,4,4} */ -#define IGA1_HOR_SYNC_START_REG_NUM 2 -/* location: {CR05,0,4} */ -#define IGA1_HOR_SYNC_END_REG_NUM 1 -/* location: {CR06,0,7},{CR07,0,0},{CR07,5,5},{CR35,0,0} */ -#define IGA1_VER_TOTAL_REG_NUM 4 -/* location: {CR12,0,7},{CR07,1,1},{CR07,6,6},{CR35,2,2} */ -#define IGA1_VER_ADDR_REG_NUM 4 -/* location: {CR15,0,7},{CR07,3,3},{CR09,5,5},{CR35,3,3} */ -#define IGA1_VER_BLANK_START_REG_NUM 4 -/* location: {CR16,0,7} */ -#define IGA1_VER_BLANK_END_REG_NUM 1 -/* location: {CR10,0,7},{CR07,2,2},{CR07,7,7},{CR35,1,1} */ -#define IGA1_VER_SYNC_START_REG_NUM 4 -/* location: {CR11,0,3} */ -#define IGA1_VER_SYNC_END_REG_NUM 1 - -/* Define Register Number for IGA2 Shadow CRTC Timing */ - -/* location: {CR6D,0,7},{CR71,3,3} */ -#define IGA2_SHADOW_HOR_TOTAL_REG_NUM 2 -/* location: {CR6E,0,7} */ -#define IGA2_SHADOW_HOR_BLANK_END_REG_NUM 1 -/* location: {CR6F,0,7},{CR71,0,2} */ -#define IGA2_SHADOW_VER_TOTAL_REG_NUM 2 -/* location: {CR70,0,7},{CR71,4,6} */ -#define IGA2_SHADOW_VER_ADDR_REG_NUM 2 -/* location: {CR72,0,7},{CR74,4,6} */ -#define IGA2_SHADOW_VER_BLANK_START_REG_NUM 2 -/* location: {CR73,0,7},{CR74,0,2} */ -#define IGA2_SHADOW_VER_BLANK_END_REG_NUM 2 -/* location: {CR75,0,7},{CR76,4,6} */ -#define IGA2_SHADOW_VER_SYNC_START_REG_NUM 2 -/* location: {CR76,0,3} */ -#define IGA2_SHADOW_VER_SYNC_END_REG_NUM 1 - -/* Define Register Number for IGA2 CRTC Timing */ - -/* location: {CR50,0,7},{CR55,0,3} */ -#define IGA2_HOR_TOTAL_REG_NUM 2 -/* location: {CR51,0,7},{CR55,4,6} */ -#define IGA2_HOR_ADDR_REG_NUM 2 -/* location: {CR52,0,7},{CR54,0,2} */ -#define IGA2_HOR_BLANK_START_REG_NUM 2 -/* location: CLE266: {CR53,0,7},{CR54,3,5} => CLE266's CR5D[6] -is reserved, so it may have problem to set 1600x1200 on IGA2. */ -/* Others: {CR53,0,7},{CR54,3,5},{CR5D,6,6} */ -#define IGA2_HOR_BLANK_END_REG_NUM 3 -/* location: {CR56,0,7},{CR54,6,7},{CR5C,7,7} */ -/* VT3314 and Later: {CR56,0,7},{CR54,6,7},{CR5C,7,7}, {CR5D,7,7} */ -#define IGA2_HOR_SYNC_START_REG_NUM 4 - -/* location: {CR57,0,7},{CR5C,6,6} */ -#define IGA2_HOR_SYNC_END_REG_NUM 2 -/* location: {CR58,0,7},{CR5D,0,2} */ -#define IGA2_VER_TOTAL_REG_NUM 2 -/* location: {CR59,0,7},{CR5D,3,5} */ -#define IGA2_VER_ADDR_REG_NUM 2 -/* location: {CR5A,0,7},{CR5C,0,2} */ -#define IGA2_VER_BLANK_START_REG_NUM 2 -/* location: {CR5E,0,7},{CR5C,3,5} */ -#define IGA2_VER_BLANK_END_REG_NUM 2 -/* location: {CR5E,0,7},{CR5F,5,7} */ -#define IGA2_VER_SYNC_START_REG_NUM 2 -/* location: {CR5F,0,4} */ -#define IGA2_VER_SYNC_END_REG_NUM 1 - -/* Define Fetch Count Register*/ - -/* location: {SR1C,0,7},{SR1D,0,1} */ -#define IGA1_FETCH_COUNT_REG_NUM 2 -/* 16 bytes alignment. */ -#define IGA1_FETCH_COUNT_ALIGN_BYTE 16 -/* x: H resolution, y: color depth */ -#define IGA1_FETCH_COUNT_PATCH_VALUE 4 -#define IGA1_FETCH_COUNT_FORMULA(x, y) \ - (((x*y)/IGA1_FETCH_COUNT_ALIGN_BYTE) + IGA1_FETCH_COUNT_PATCH_VALUE) - -/* location: {CR65,0,7},{CR67,2,3} */ -#define IGA2_FETCH_COUNT_REG_NUM 2 -#define IGA2_FETCH_COUNT_ALIGN_BYTE 16 -#define IGA2_FETCH_COUNT_PATCH_VALUE 0 -#define IGA2_FETCH_COUNT_FORMULA(x, y) \ - (((x*y)/IGA2_FETCH_COUNT_ALIGN_BYTE) + IGA2_FETCH_COUNT_PATCH_VALUE) - -/* Staring Address*/ - -/* location: {CR0C,0,7},{CR0D,0,7},{CR34,0,7},{CR48,0,1} */ -#define IGA1_STARTING_ADDR_REG_NUM 4 -/* location: {CR62,1,7},{CR63,0,7},{CR64,0,7} */ -#define IGA2_STARTING_ADDR_REG_NUM 3 - -/* Define Display OFFSET*/ -/* These value are by HW suggested value*/ -/* location: {SR17,0,7} */ -#define K800_IGA1_FIFO_MAX_DEPTH 384 -/* location: {SR16,0,5},{SR16,7,7} */ -#define K800_IGA1_FIFO_THRESHOLD 328 -/* location: {SR18,0,5},{SR18,7,7} */ -#define K800_IGA1_FIFO_HIGH_THRESHOLD 296 -/* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */ - /* because HW only 5 bits */ -#define K800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0 - -/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */ -#define K800_IGA2_FIFO_MAX_DEPTH 384 -/* location: {CR68,0,3},{CR95,4,6} */ -#define K800_IGA2_FIFO_THRESHOLD 328 -/* location: {CR92,0,3},{CR95,0,2} */ -#define K800_IGA2_FIFO_HIGH_THRESHOLD 296 -/* location: {CR94,0,6} */ -#define K800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128 - -/* location: {SR17,0,7} */ -#define P880_IGA1_FIFO_MAX_DEPTH 192 -/* location: {SR16,0,5},{SR16,7,7} */ -#define P880_IGA1_FIFO_THRESHOLD 128 -/* location: {SR18,0,5},{SR18,7,7} */ -#define P880_IGA1_FIFO_HIGH_THRESHOLD 64 -/* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */ - /* because HW only 5 bits */ -#define P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0 - -/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */ -#define P880_IGA2_FIFO_MAX_DEPTH 96 -/* location: {CR68,0,3},{CR95,4,6} */ -#define P880_IGA2_FIFO_THRESHOLD 64 -/* location: {CR92,0,3},{CR95,0,2} */ -#define P880_IGA2_FIFO_HIGH_THRESHOLD 32 -/* location: {CR94,0,6} */ -#define P880_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128 - -/* VT3314 chipset*/ - -/* location: {SR17,0,7} */ -#define CN700_IGA1_FIFO_MAX_DEPTH 96 -/* location: {SR16,0,5},{SR16,7,7} */ -#define CN700_IGA1_FIFO_THRESHOLD 80 -/* location: {SR18,0,5},{SR18,7,7} */ -#define CN700_IGA1_FIFO_HIGH_THRESHOLD 64 -/* location: {SR22,0,4}. (128/4) =64, P800 must be set zero, - because HW only 5 bits */ -#define CN700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0 -/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */ -#define CN700_IGA2_FIFO_MAX_DEPTH 96 -/* location: {CR68,0,3},{CR95,4,6} */ -#define CN700_IGA2_FIFO_THRESHOLD 80 -/* location: {CR92,0,3},{CR95,0,2} */ -#define CN700_IGA2_FIFO_HIGH_THRESHOLD 32 -/* location: {CR94,0,6} */ -#define CN700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128 - -/* For VT3324, these values are suggested by HW */ -/* location: {SR17,0,7} */ -#define CX700_IGA1_FIFO_MAX_DEPTH 192 -/* location: {SR16,0,5},{SR16,7,7} */ -#define CX700_IGA1_FIFO_THRESHOLD 128 -/* location: {SR18,0,5},{SR18,7,7} */ -#define CX700_IGA1_FIFO_HIGH_THRESHOLD 128 -/* location: {SR22,0,4} */ -#define CX700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124 - -/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */ -#define CX700_IGA2_FIFO_MAX_DEPTH 96 -/* location: {CR68,0,3},{CR95,4,6} */ -#define CX700_IGA2_FIFO_THRESHOLD 64 -/* location: {CR92,0,3},{CR95,0,2} */ -#define CX700_IGA2_FIFO_HIGH_THRESHOLD 32 -/* location: {CR94,0,6} */ -#define CX700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128 - -/* VT3336 chipset*/ -/* location: {SR17,0,7} */ -#define K8M890_IGA1_FIFO_MAX_DEPTH 360 -/* location: {SR16,0,5},{SR16,7,7} */ -#define K8M890_IGA1_FIFO_THRESHOLD 328 -/* location: {SR18,0,5},{SR18,7,7} */ -#define K8M890_IGA1_FIFO_HIGH_THRESHOLD 296 -/* location: {SR22,0,4}. */ -#define K8M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124 - -/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */ -#define K8M890_IGA2_FIFO_MAX_DEPTH 360 -/* location: {CR68,0,3},{CR95,4,6} */ -#define K8M890_IGA2_FIFO_THRESHOLD 328 -/* location: {CR92,0,3},{CR95,0,2} */ -#define K8M890_IGA2_FIFO_HIGH_THRESHOLD 296 -/* location: {CR94,0,6} */ -#define K8M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 124 - -/* VT3327 chipset*/ -/* location: {SR17,0,7} */ -#define P4M890_IGA1_FIFO_MAX_DEPTH 96 -/* location: {SR16,0,5},{SR16,7,7} */ -#define P4M890_IGA1_FIFO_THRESHOLD 76 -/* location: {SR18,0,5},{SR18,7,7} */ -#define P4M890_IGA1_FIFO_HIGH_THRESHOLD 64 -/* location: {SR22,0,4}. (32/4) =8 */ -#define P4M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32 -/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */ -#define P4M890_IGA2_FIFO_MAX_DEPTH 96 -/* location: {CR68,0,3},{CR95,4,6} */ -#define P4M890_IGA2_FIFO_THRESHOLD 76 -/* location: {CR92,0,3},{CR95,0,2} */ -#define P4M890_IGA2_FIFO_HIGH_THRESHOLD 64 -/* location: {CR94,0,6} */ -#define P4M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32 - -/* VT3364 chipset*/ -/* location: {SR17,0,7} */ -#define P4M900_IGA1_FIFO_MAX_DEPTH 96 -/* location: {SR16,0,5},{SR16,7,7} */ -#define P4M900_IGA1_FIFO_THRESHOLD 76 -/* location: {SR18,0,5},{SR18,7,7} */ -#define P4M900_IGA1_FIFO_HIGH_THRESHOLD 76 -/* location: {SR22,0,4}. */ -#define P4M900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32 -/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */ -#define P4M900_IGA2_FIFO_MAX_DEPTH 96 -/* location: {CR68,0,3},{CR95,4,6} */ -#define P4M900_IGA2_FIFO_THRESHOLD 76 -/* location: {CR92,0,3},{CR95,0,2} */ -#define P4M900_IGA2_FIFO_HIGH_THRESHOLD 76 -/* location: {CR94,0,6} */ -#define P4M900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32 - -/* For VT3353, these values are suggested by HW */ -/* location: {SR17,0,7} */ -#define VX800_IGA1_FIFO_MAX_DEPTH 192 -/* location: {SR16,0,5},{SR16,7,7} */ -#define VX800_IGA1_FIFO_THRESHOLD 152 -/* location: {SR18,0,5},{SR18,7,7} */ -#define VX800_IGA1_FIFO_HIGH_THRESHOLD 152 -/* location: {SR22,0,4} */ -#define VX800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 64 -/* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */ -#define VX800_IGA2_FIFO_MAX_DEPTH 96 -/* location: {CR68,0,3},{CR95,4,6} */ -#define VX800_IGA2_FIFO_THRESHOLD 64 -/* location: {CR92,0,3},{CR95,0,2} */ -#define VX800_IGA2_FIFO_HIGH_THRESHOLD 32 -/* location: {CR94,0,6} */ -#define VX800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128 - -/* For VT3409 */ -#define VX855_IGA1_FIFO_MAX_DEPTH 400 -#define VX855_IGA1_FIFO_THRESHOLD 320 -#define VX855_IGA1_FIFO_HIGH_THRESHOLD 320 -#define VX855_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 160 - -#define VX855_IGA2_FIFO_MAX_DEPTH 200 -#define VX855_IGA2_FIFO_THRESHOLD 160 -#define VX855_IGA2_FIFO_HIGH_THRESHOLD 160 -#define VX855_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 320 - -/* For VT3410 */ -#define VX900_IGA1_FIFO_MAX_DEPTH 400 -#define VX900_IGA1_FIFO_THRESHOLD 320 -#define VX900_IGA1_FIFO_HIGH_THRESHOLD 320 -#define VX900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 160 - -#define VX900_IGA2_FIFO_MAX_DEPTH 192 -#define VX900_IGA2_FIFO_THRESHOLD 160 -#define VX900_IGA2_FIFO_HIGH_THRESHOLD 160 -#define VX900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 320 - -#define IGA1_FIFO_DEPTH_SELECT_REG_NUM 1 -#define IGA1_FIFO_THRESHOLD_REG_NUM 2 -#define IGA1_FIFO_HIGH_THRESHOLD_REG_NUM 2 -#define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1 - -#define IGA2_FIFO_DEPTH_SELECT_REG_NUM 3 -#define IGA2_FIFO_THRESHOLD_REG_NUM 2 -#define IGA2_FIFO_HIGH_THRESHOLD_REG_NUM 2 -#define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1 - -#define IGA1_FIFO_DEPTH_SELECT_FORMULA(x) ((x/2)-1) -#define IGA1_FIFO_THRESHOLD_FORMULA(x) (x/4) -#define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4) -#define IGA1_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4) -#define IGA2_FIFO_DEPTH_SELECT_FORMULA(x) (((x/2)/4)-1) -#define IGA2_FIFO_THRESHOLD_FORMULA(x) (x/4) -#define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4) -#define IGA2_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4) - -/************************************************************************/ -/* LCD Timing */ -/************************************************************************/ - -/* 500 ms = 500000 us */ -#define LCD_POWER_SEQ_TD0 500000 -/* 50 ms = 50000 us */ -#define LCD_POWER_SEQ_TD1 50000 -/* 0 us */ -#define LCD_POWER_SEQ_TD2 0 -/* 210 ms = 210000 us */ -#define LCD_POWER_SEQ_TD3 210000 -/* 2^10 * (1/14.31818M) = 71.475 us (K400.revA) */ -#define CLE266_POWER_SEQ_UNIT 71 -/* 2^11 * (1/14.31818M) = 142.95 us (K400.revB) */ -#define K800_POWER_SEQ_UNIT 142 -/* 2^13 * (1/14.31818M) = 572.1 us */ -#define P880_POWER_SEQ_UNIT 572 - -#define CLE266_POWER_SEQ_FORMULA(x) ((x)/CLE266_POWER_SEQ_UNIT) -#define K800_POWER_SEQ_FORMULA(x) ((x)/K800_POWER_SEQ_UNIT) -#define P880_POWER_SEQ_FORMULA(x) ((x)/P880_POWER_SEQ_UNIT) - -/* location: {CR8B,0,7},{CR8F,0,3} */ -#define LCD_POWER_SEQ_TD0_REG_NUM 2 -/* location: {CR8C,0,7},{CR8F,4,7} */ -#define LCD_POWER_SEQ_TD1_REG_NUM 2 -/* location: {CR8D,0,7},{CR90,0,3} */ -#define LCD_POWER_SEQ_TD2_REG_NUM 2 -/* location: {CR8E,0,7},{CR90,4,7} */ -#define LCD_POWER_SEQ_TD3_REG_NUM 2 - -/* LCD Scaling factor*/ -/* x: indicate setting horizontal size*/ -/* y: indicate panel horizontal size*/ - -/* Horizontal scaling factor 10 bits (2^10) */ -#define CLE266_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1)) -/* Vertical scaling factor 10 bits (2^10) */ -#define CLE266_LCD_VER_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1)) -/* Horizontal scaling factor 10 bits (2^12) */ -#define K800_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*4096)/(y-1)) -/* Vertical scaling factor 10 bits (2^11) */ -#define K800_LCD_VER_SCF_FORMULA(x, y) (((x-1)*2048)/(y-1)) - -/* location: {CR9F,0,1},{CR77,0,7},{CR79,4,5} */ -#define LCD_HOR_SCALING_FACTOR_REG_NUM 3 -/* location: {CR79,3,3},{CR78,0,7},{CR79,6,7} */ -#define LCD_VER_SCALING_FACTOR_REG_NUM 3 -/* location: {CR77,0,7},{CR79,4,5} */ -#define LCD_HOR_SCALING_FACTOR_REG_NUM_CLE 2 -/* location: {CR78,0,7},{CR79,6,7} */ -#define LCD_VER_SCALING_FACTOR_REG_NUM_CLE 2 - -/************************************************ - ***** Define IGA1 Display Timing ***** - ************************************************/ -struct io_register { - u8 io_addr; - u8 start_bit; - u8 end_bit; -}; - -/* IGA1 Horizontal Total */ -struct iga1_hor_total { - int reg_num; - struct io_register reg[IGA1_HOR_TOTAL_REG_NUM]; -}; - -/* IGA1 Horizontal Addressable Video */ -struct iga1_hor_addr { - int reg_num; - struct io_register reg[IGA1_HOR_ADDR_REG_NUM]; -}; - -/* IGA1 Horizontal Blank Start */ -struct iga1_hor_blank_start { - int reg_num; - struct io_register reg[IGA1_HOR_BLANK_START_REG_NUM]; -}; - -/* IGA1 Horizontal Blank End */ -struct iga1_hor_blank_end { - int reg_num; - struct io_register reg[IGA1_HOR_BLANK_END_REG_NUM]; -}; - -/* IGA1 Horizontal Sync Start */ -struct iga1_hor_sync_start { - int reg_num; - struct io_register reg[IGA1_HOR_SYNC_START_REG_NUM]; -}; - -/* IGA1 Horizontal Sync End */ -struct iga1_hor_sync_end { - int reg_num; - struct io_register reg[IGA1_HOR_SYNC_END_REG_NUM]; -}; - -/* IGA1 Vertical Total */ -struct iga1_ver_total { - int reg_num; - struct io_register reg[IGA1_VER_TOTAL_REG_NUM]; -}; - -/* IGA1 Vertical Addressable Video */ -struct iga1_ver_addr { - int reg_num; - struct io_register reg[IGA1_VER_ADDR_REG_NUM]; -}; - -/* IGA1 Vertical Blank Start */ -struct iga1_ver_blank_start { - int reg_num; - struct io_register reg[IGA1_VER_BLANK_START_REG_NUM]; -}; - -/* IGA1 Vertical Blank End */ -struct iga1_ver_blank_end { - int reg_num; - struct io_register reg[IGA1_VER_BLANK_END_REG_NUM]; -}; - -/* IGA1 Vertical Sync Start */ -struct iga1_ver_sync_start { - int reg_num; - struct io_register reg[IGA1_VER_SYNC_START_REG_NUM]; -}; - -/* IGA1 Vertical Sync End */ -struct iga1_ver_sync_end { - int reg_num; - struct io_register reg[IGA1_VER_SYNC_END_REG_NUM]; -}; - -/***************************************************** -** Define IGA2 Shadow Display Timing **** -*****************************************************/ - -/* IGA2 Shadow Horizontal Total */ -struct iga2_shadow_hor_total { - int reg_num; - struct io_register reg[IGA2_SHADOW_HOR_TOTAL_REG_NUM]; -}; - -/* IGA2 Shadow Horizontal Blank End */ -struct iga2_shadow_hor_blank_end { - int reg_num; - struct io_register reg[IGA2_SHADOW_HOR_BLANK_END_REG_NUM]; -}; - -/* IGA2 Shadow Vertical Total */ -struct iga2_shadow_ver_total { - int reg_num; - struct io_register reg[IGA2_SHADOW_VER_TOTAL_REG_NUM]; -}; - -/* IGA2 Shadow Vertical Addressable Video */ -struct iga2_shadow_ver_addr { - int reg_num; - struct io_register reg[IGA2_SHADOW_VER_ADDR_REG_NUM]; -}; - -/* IGA2 Shadow Vertical Blank Start */ -struct iga2_shadow_ver_blank_start { - int reg_num; - struct io_register reg[IGA2_SHADOW_VER_BLANK_START_REG_NUM]; -}; - -/* IGA2 Shadow Vertical Blank End */ -struct iga2_shadow_ver_blank_end { - int reg_num; - struct io_register reg[IGA2_SHADOW_VER_BLANK_END_REG_NUM]; -}; - -/* IGA2 Shadow Vertical Sync Start */ -struct iga2_shadow_ver_sync_start { - int reg_num; - struct io_register reg[IGA2_SHADOW_VER_SYNC_START_REG_NUM]; -}; - -/* IGA2 Shadow Vertical Sync End */ -struct iga2_shadow_ver_sync_end { - int reg_num; - struct io_register reg[IGA2_SHADOW_VER_SYNC_END_REG_NUM]; -}; - -/***************************************************** -** Define IGA2 Display Timing **** -******************************************************/ - -/* IGA2 Horizontal Total */ -struct iga2_hor_total { - int reg_num; - struct io_register reg[IGA2_HOR_TOTAL_REG_NUM]; -}; - -/* IGA2 Horizontal Addressable Video */ -struct iga2_hor_addr { - int reg_num; - struct io_register reg[IGA2_HOR_ADDR_REG_NUM]; -}; - -/* IGA2 Horizontal Blank Start */ -struct iga2_hor_blank_start { - int reg_num; - struct io_register reg[IGA2_HOR_BLANK_START_REG_NUM]; -}; - -/* IGA2 Horizontal Blank End */ -struct iga2_hor_blank_end { - int reg_num; - struct io_register reg[IGA2_HOR_BLANK_END_REG_NUM]; -}; - -/* IGA2 Horizontal Sync Start */ -struct iga2_hor_sync_start { - int reg_num; - struct io_register reg[IGA2_HOR_SYNC_START_REG_NUM]; -}; - -/* IGA2 Horizontal Sync End */ -struct iga2_hor_sync_end { - int reg_num; - struct io_register reg[IGA2_HOR_SYNC_END_REG_NUM]; -}; - -/* IGA2 Vertical Total */ -struct iga2_ver_total { - int reg_num; - struct io_register reg[IGA2_VER_TOTAL_REG_NUM]; -}; - -/* IGA2 Vertical Addressable Video */ -struct iga2_ver_addr { - int reg_num; - struct io_register reg[IGA2_VER_ADDR_REG_NUM]; -}; - -/* IGA2 Vertical Blank Start */ -struct iga2_ver_blank_start { - int reg_num; - struct io_register reg[IGA2_VER_BLANK_START_REG_NUM]; -}; - -/* IGA2 Vertical Blank End */ -struct iga2_ver_blank_end { - int reg_num; - struct io_register reg[IGA2_VER_BLANK_END_REG_NUM]; -}; - -/* IGA2 Vertical Sync Start */ -struct iga2_ver_sync_start { - int reg_num; - struct io_register reg[IGA2_VER_SYNC_START_REG_NUM]; -}; - -/* IGA2 Vertical Sync End */ -struct iga2_ver_sync_end { - int reg_num; - struct io_register reg[IGA2_VER_SYNC_END_REG_NUM]; -}; - -/* IGA1 Fetch Count Register */ -struct iga1_fetch_count { - int reg_num; - struct io_register reg[IGA1_FETCH_COUNT_REG_NUM]; -}; - -/* IGA2 Fetch Count Register */ -struct iga2_fetch_count { - int reg_num; - struct io_register reg[IGA2_FETCH_COUNT_REG_NUM]; -}; - -struct fetch_count { - struct iga1_fetch_count iga1_fetch_count_reg; - struct iga2_fetch_count iga2_fetch_count_reg; -}; - -/* Starting Address Register */ -struct iga1_starting_addr { - int reg_num; - struct io_register reg[IGA1_STARTING_ADDR_REG_NUM]; -}; - -struct iga2_starting_addr { - int reg_num; - struct io_register reg[IGA2_STARTING_ADDR_REG_NUM]; -}; - -struct starting_addr { - struct iga1_starting_addr iga1_starting_addr_reg; - struct iga2_starting_addr iga2_starting_addr_reg; -}; - -/* LCD Power Sequence Timer */ -struct lcd_pwd_seq_td0 { - int reg_num; - struct io_register reg[LCD_POWER_SEQ_TD0_REG_NUM]; -}; - -struct lcd_pwd_seq_td1 { - int reg_num; - struct io_register reg[LCD_POWER_SEQ_TD1_REG_NUM]; -}; - -struct lcd_pwd_seq_td2 { - int reg_num; - struct io_register reg[LCD_POWER_SEQ_TD2_REG_NUM]; -}; - -struct lcd_pwd_seq_td3 { - int reg_num; - struct io_register reg[LCD_POWER_SEQ_TD3_REG_NUM]; -}; - -struct _lcd_pwd_seq_timer { - struct lcd_pwd_seq_td0 td0; - struct lcd_pwd_seq_td1 td1; - struct lcd_pwd_seq_td2 td2; - struct lcd_pwd_seq_td3 td3; -}; - -/* LCD Scaling Factor */ -struct _lcd_hor_scaling_factor { - int reg_num; - struct io_register reg[LCD_HOR_SCALING_FACTOR_REG_NUM]; -}; - -struct _lcd_ver_scaling_factor { - int reg_num; - struct io_register reg[LCD_VER_SCALING_FACTOR_REG_NUM]; -}; - -struct _lcd_scaling_factor { - struct _lcd_hor_scaling_factor lcd_hor_scaling_factor; - struct _lcd_ver_scaling_factor lcd_ver_scaling_factor; -}; - -struct pll_config { - u16 multiplier; - u8 divisor; - u8 rshift; -}; - -struct pll_map { - u32 clk; - struct pll_config cle266_pll; - struct pll_config k800_pll; - struct pll_config cx700_pll; - struct pll_config vx855_pll; -}; - -struct rgbLUT { - u8 red; - u8 green; - u8 blue; -}; - -struct lcd_pwd_seq_timer { - u16 td0; - u16 td1; - u16 td2; - u16 td3; -}; - -/* Display FIFO Relation Registers*/ -struct iga1_fifo_depth_select { - int reg_num; - struct io_register reg[IGA1_FIFO_DEPTH_SELECT_REG_NUM]; -}; - -struct iga1_fifo_threshold_select { - int reg_num; - struct io_register reg[IGA1_FIFO_THRESHOLD_REG_NUM]; -}; - -struct iga1_fifo_high_threshold_select { - int reg_num; - struct io_register reg[IGA1_FIFO_HIGH_THRESHOLD_REG_NUM]; -}; - -struct iga1_display_queue_expire_num { - int reg_num; - struct io_register reg[IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM]; -}; - -struct iga2_fifo_depth_select { - int reg_num; - struct io_register reg[IGA2_FIFO_DEPTH_SELECT_REG_NUM]; -}; - -struct iga2_fifo_threshold_select { - int reg_num; - struct io_register reg[IGA2_FIFO_THRESHOLD_REG_NUM]; -}; - -struct iga2_fifo_high_threshold_select { - int reg_num; - struct io_register reg[IGA2_FIFO_HIGH_THRESHOLD_REG_NUM]; -}; - -struct iga2_display_queue_expire_num { - int reg_num; - struct io_register reg[IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM]; -}; - -struct fifo_depth_select { - struct iga1_fifo_depth_select iga1_fifo_depth_select_reg; - struct iga2_fifo_depth_select iga2_fifo_depth_select_reg; -}; - -struct fifo_threshold_select { - struct iga1_fifo_threshold_select iga1_fifo_threshold_select_reg; - struct iga2_fifo_threshold_select iga2_fifo_threshold_select_reg; -}; - -struct fifo_high_threshold_select { - struct iga1_fifo_high_threshold_select - iga1_fifo_high_threshold_select_reg; - struct iga2_fifo_high_threshold_select - iga2_fifo_high_threshold_select_reg; -}; - -struct display_queue_expire_num { - struct iga1_display_queue_expire_num - iga1_display_queue_expire_num_reg; - struct iga2_display_queue_expire_num - iga2_display_queue_expire_num_reg; -}; - -struct iga1_crtc_timing { - struct iga1_hor_total hor_total; - struct iga1_hor_addr hor_addr; - struct iga1_hor_blank_start hor_blank_start; - struct iga1_hor_blank_end hor_blank_end; - struct iga1_hor_sync_start hor_sync_start; - struct iga1_hor_sync_end hor_sync_end; - struct iga1_ver_total ver_total; - struct iga1_ver_addr ver_addr; - struct iga1_ver_blank_start ver_blank_start; - struct iga1_ver_blank_end ver_blank_end; - struct iga1_ver_sync_start ver_sync_start; - struct iga1_ver_sync_end ver_sync_end; -}; - -struct iga2_shadow_crtc_timing { - struct iga2_shadow_hor_total hor_total_shadow; - struct iga2_shadow_hor_blank_end hor_blank_end_shadow; - struct iga2_shadow_ver_total ver_total_shadow; - struct iga2_shadow_ver_addr ver_addr_shadow; - struct iga2_shadow_ver_blank_start ver_blank_start_shadow; - struct iga2_shadow_ver_blank_end ver_blank_end_shadow; - struct iga2_shadow_ver_sync_start ver_sync_start_shadow; - struct iga2_shadow_ver_sync_end ver_sync_end_shadow; -}; - -struct iga2_crtc_timing { - struct iga2_hor_total hor_total; - struct iga2_hor_addr hor_addr; - struct iga2_hor_blank_start hor_blank_start; - struct iga2_hor_blank_end hor_blank_end; - struct iga2_hor_sync_start hor_sync_start; - struct iga2_hor_sync_end hor_sync_end; - struct iga2_ver_total ver_total; - struct iga2_ver_addr ver_addr; - struct iga2_ver_blank_start ver_blank_start; - struct iga2_ver_blank_end ver_blank_end; - struct iga2_ver_sync_start ver_sync_start; - struct iga2_ver_sync_end ver_sync_end; -}; - -/* device ID */ -#define CLE266_FUNCTION3 0x3123 -#define KM400_FUNCTION3 0x3205 -#define CN400_FUNCTION2 0x2259 -#define CN400_FUNCTION3 0x3259 -/* support VT3314 chipset */ -#define CN700_FUNCTION2 0x2314 -#define CN700_FUNCTION3 0x3208 -/* VT3324 chipset */ -#define CX700_FUNCTION2 0x2324 -#define CX700_FUNCTION3 0x3324 -/* VT3204 chipset*/ -#define KM800_FUNCTION3 0x3204 -/* VT3336 chipset*/ -#define KM890_FUNCTION3 0x3336 -/* VT3327 chipset*/ -#define P4M890_FUNCTION3 0x3327 -/* VT3293 chipset*/ -#define CN750_FUNCTION3 0x3208 -/* VT3364 chipset*/ -#define P4M900_FUNCTION3 0x3364 -/* VT3353 chipset*/ -#define VX800_FUNCTION3 0x3353 -/* VT3409 chipset*/ -#define VX855_FUNCTION3 0x3409 -/* VT3410 chipset*/ -#define VX900_FUNCTION3 0x3410 - -#define NUM_TOTAL_PLL_TABLE ARRAY_SIZE(pll_value) - -struct IODATA { - u8 Index; - u8 Mask; - u8 Data; -}; - -struct pci_device_id_info { - u32 vendor; - u32 device; - u32 chip_index; -}; - -struct via_device_mapping { - u32 device; - const char *name; -}; - -extern unsigned int viafb_second_virtual_xres; -extern int viafb_SAMM_ON; -extern int viafb_dual_fb; -extern int viafb_LCD2_ON; -extern int viafb_LCD_ON; -extern int viafb_DVI_ON; -extern int viafb_hotplug; - -void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, - struct VideoModeTable *video_mode, int bpp_byte, int set_iga); - -void viafb_set_vclock(u32 CLK, int set_iga); -void viafb_load_reg(int timing_value, int viafb_load_reg_num, - struct io_register *reg, - int io_type); -void via_set_source(u32 devices, u8 iga); -void via_set_state(u32 devices, u8 state); -void via_set_sync_polarity(u32 devices, u8 polarity); -u32 via_parse_odev(char *input, char **end); -void via_odev_to_seq(struct seq_file *m, u32 odev); -void init_ad9389(void); -/* Access I/O Function */ -void viafb_lock_crt(void); -void viafb_unlock_crt(void); -void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga); -void viafb_write_regx(struct io_reg RegTable[], int ItemNum); -u32 viafb_get_clk_value(int clk); -void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active); -void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ - *p_gfx_dpa_setting); - -int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp, - struct VideoModeTable *vmode_tbl1, int video_bpp1); -void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, - struct VideoModeTable *vmode_tbl); -void __devinit viafb_init_chip_info(int chip_type); -void __devinit viafb_init_dac(int set_iga); -int viafb_get_pixclock(int hres, int vres, int vmode_refresh); -int viafb_get_refresh(int hres, int vres, u32 float_refresh); -void viafb_update_device_setting(int hres, int vres, int bpp, - int vmode_refresh, int flag); - -void viafb_set_iga_path(void); -void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue); -void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue); -void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len); - -#endif /* __HW_H__ */ diff --git a/drivers/video/via/ioctl.c b/drivers/video/via/ioctl.c deleted file mode 100644 index ea1c5142882..00000000000 --- a/drivers/video/via/ioctl.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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; - - memset(&viainfo, 0, sizeof(struct viafb_ioctl_info)); - - 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; - viafb_set_iga_path(); - 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; - viafb_set_iga_path(); - return viafb_DeviceStatus; - } - - return 0; -} diff --git a/drivers/video/via/ioctl.h b/drivers/video/via/ioctl.h deleted file mode 100644 index 6010d10b59e..00000000000 --- a/drivers/video/via/ioctl.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * 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 __IOCTL_H__ -#define __IOCTL_H__ - -#ifndef __user -#define __user -#endif - -/* VIAFB IOCTL definition */ -#define VIAFB_GET_INFO_SIZE 0x56494101 /* 'VIA\01' */ -#define VIAFB_GET_INFO 0x56494102 /* 'VIA\02' */ -#define VIAFB_HOTPLUG 0x56494103 /* 'VIA\03' */ -#define VIAFB_SET_HOTPLUG_FLAG 0x56494104 /* 'VIA\04' */ -#define VIAFB_GET_RESOLUTION 0x56494105 /* 'VIA\05' */ -#define VIAFB_GET_SAMM_INFO 0x56494107 /* 'VIA\07' */ -#define VIAFB_TURN_ON_OUTPUT_DEVICE 0x56494108 /* 'VIA\08' */ -#define VIAFB_TURN_OFF_OUTPUT_DEVICE 0x56494109 /* 'VIA\09' */ -#define VIAFB_GET_DEVICE 0x5649410B -#define VIAFB_GET_DRIVER_VERSION 0x56494112 /* 'VIA\12' */ -#define VIAFB_GET_CHIP_INFO 0x56494113 /* 'VIA\13' */ -#define VIAFB_GET_DEVICE_INFO 0x56494115 - -#define VIAFB_GET_DEVICE_SUPPORT 0x56494118 -#define VIAFB_GET_DEVICE_CONNECT 0x56494119 -#define VIAFB_GET_PANEL_SUPPORT_EXPAND 0x5649411A -#define VIAFB_GET_DRIVER_NAME 0x56494122 -#define VIAFB_GET_DEVICE_SUPPORT_STATE 0x56494123 -#define VIAFB_GET_GAMMA_LUT 0x56494124 -#define VIAFB_SET_GAMMA_LUT 0x56494125 -#define VIAFB_GET_GAMMA_SUPPORT_STATE 0x56494126 -#define VIAFB_SYNC_SURFACE 0x56494130 -#define VIAFB_GET_DRIVER_CAPS 0x56494131 -#define VIAFB_GET_IGA_SCALING_INFO 0x56494132 -#define VIAFB_GET_PANEL_MAX_SIZE 0x56494133 -#define VIAFB_GET_PANEL_MAX_POSITION 0x56494134 -#define VIAFB_SET_PANEL_SIZE 0x56494135 -#define VIAFB_SET_PANEL_POSITION 0x56494136 -#define VIAFB_GET_PANEL_POSITION 0x56494137 -#define VIAFB_GET_PANEL_SIZE 0x56494138 - -#define None_Device 0x00 -#define CRT_Device 0x01 -#define LCD_Device 0x02 -#define DVI_Device 0x08 -#define CRT2_Device 0x10 -#define LCD2_Device 0x40 - -#define OP_LCD_CENTERING 0x01 -#define OP_LCD_PANEL_ID 0x02 -#define OP_LCD_MODE 0x03 - -/*SAMM operation flag*/ -#define OP_SAMM 0x80 - -#define LCD_PANEL_ID_MAXIMUM 23 - -#define STATE_ON 0x1 -#define STATE_OFF 0x0 -#define STATE_DEFAULT 0xFFFF - -#define MAX_ACTIVE_DEV_NUM 2 - -struct device_t { - unsigned short crt:1; - unsigned short dvi:1; - unsigned short lcd:1; - unsigned short samm:1; - unsigned short lcd_dsp_cent:1; - unsigned char lcd_mode:1; - unsigned short epia_dvi:1; - unsigned short lcd_dual_edge:1; - unsigned short lcd2:1; - - unsigned short primary_dev; - unsigned char lcd_panel_id; - unsigned short xres, yres; - unsigned short xres1, yres1; - unsigned short refresh; - unsigned short bpp; - unsigned short refresh1; - unsigned short bpp1; - unsigned short sequence; - unsigned short bus_width; -}; - -struct viafb_ioctl_info { - u32 viafb_id; /* for identifying viafb */ -#define VIAID 0x56494146 /* Identify myself with 'VIAF' */ - u16 vendor_id; - u16 device_id; - u8 version; - u8 revision; - u8 reserved[246]; /* for future use */ -}; - -struct viafb_ioctl_mode { - u32 xres; - u32 yres; - u32 refresh; - u32 bpp; - u32 xres_sec; - u32 yres_sec; - u32 virtual_xres_sec; - u32 virtual_yres_sec; - u32 refresh_sec; - u32 bpp_sec; -}; -struct viafb_ioctl_samm { - u32 samm_status; - u32 size_prim; - u32 size_sec; - u32 mem_base; - u32 offset_sec; -}; - -struct viafb_driver_version { - int iMajorNum; - int iKernelNum; - int iOSNum; - int iMinorNum; -}; - -struct viafb_ioctl_lcd_attribute { - unsigned int panel_id; - unsigned int display_center; - unsigned int lcd_mode; -}; - -struct viafb_ioctl_setting { - /* Enable or disable active devices */ - unsigned short device_flag; - /* Indicate which device should be turn on or turn off. */ - unsigned short device_status; - unsigned int reserved; - /* Indicate which LCD's attribute can be changed. */ - unsigned short lcd_operation_flag; - /* 1: SAMM ON 0: SAMM OFF */ - unsigned short samm_status; - /* horizontal resolution of first device */ - unsigned short first_dev_hor_res; - /* vertical resolution of first device */ - unsigned short first_dev_ver_res; - /* horizontal resolution of second device */ - unsigned short second_dev_hor_res; - /* vertical resolution of second device */ - unsigned short second_dev_ver_res; - /* refresh rate of first device */ - unsigned short first_dev_refresh; - /* bpp of first device */ - unsigned short first_dev_bpp; - /* refresh rate of second device */ - unsigned short second_dev_refresh; - /* bpp of second device */ - unsigned short second_dev_bpp; - /* Indicate which device are primary display device. */ - unsigned int primary_device; - unsigned int struct_reserved[35]; - struct viafb_ioctl_lcd_attribute lcd_attributes; -}; - -struct _UTFunctionCaps { - unsigned int dw3DScalingState; - unsigned int reserved[31]; -}; - -struct _POSITIONVALUE { - unsigned int dwX; - unsigned int dwY; -}; - -struct _panel_size_pos_info { - unsigned int device_type; - int x; - int y; -}; - -extern int viafb_LCD_ON; -extern int viafb_DVI_ON; - -int viafb_ioctl_get_viafb_info(u_long arg); -int viafb_ioctl_hotplug(int hres, int vres, int bpp); - -#endif /* __IOCTL_H__ */ diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c deleted file mode 100644 index 3425c396980..00000000000 --- a/drivers/video/via/lcd.c +++ /dev/null @@ -1,1108 +0,0 @@ -/* - * 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 <linux/via-core.h> -#include <linux/via_i2c.h> -#include "global.h" - -#define viafb_compact_res(x, y) (((x)<<16)|(y)) - -/* CLE266 Software Power Sequence */ -/* {Mask}, {Data}, {Delay} */ -int PowerSequenceOn[3][3] = { {0x10, 0x08, 0x06}, {0x10, 0x08, 0x06}, - {0x19, 0x1FE, 0x01} }; -int PowerSequenceOff[3][3] = { {0x06, 0x08, 0x10}, {0x00, 0x00, 0x00}, - {0xD2, 0x19, 0x01} }; - -static struct _lcd_scaling_factor lcd_scaling_factor = { - /* LCD Horizontal Scaling Factor Register */ - {LCD_HOR_SCALING_FACTOR_REG_NUM, - {{CR9F, 0, 1}, {CR77, 0, 7}, {CR79, 4, 5} } }, - /* LCD Vertical Scaling Factor Register */ - {LCD_VER_SCALING_FACTOR_REG_NUM, - {{CR79, 3, 3}, {CR78, 0, 7}, {CR79, 6, 7} } } -}; -static struct _lcd_scaling_factor lcd_scaling_factor_CLE = { - /* LCD Horizontal Scaling Factor Register */ - {LCD_HOR_SCALING_FACTOR_REG_NUM_CLE, {{CR77, 0, 7}, {CR79, 4, 5} } }, - /* LCD Vertical Scaling Factor Register */ - {LCD_VER_SCALING_FACTOR_REG_NUM_CLE, {{CR78, 0, 7}, {CR79, 6, 7} } } -}; - -static int check_lvds_chip(int device_id_subaddr, int device_id); -static bool lvds_identify_integratedlvds(void); -static void __devinit fp_id_to_vindex(int panel_id); -static int lvds_register_read(int index); -static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, - int panel_vres); -static void via_pitch_alignment_patch_lcd( - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information - *plvds_chip_info); -static void lcd_patch_skew_dvp0(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -static void lcd_patch_skew_dvp1(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -static void lcd_patch_skew(struct lvds_setting_information - *plvds_setting_info, struct lvds_chip_information *plvds_chip_info); - -static void integrated_lvds_disable(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -static void integrated_lvds_enable(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -static void lcd_powersequence_off(void); -static void lcd_powersequence_on(void); -static void fill_lcd_format(void); -static void check_diport_of_integrated_lvds( - struct lvds_chip_information *plvds_chip_info, - struct lvds_setting_information - *plvds_setting_info); -static struct display_timing lcd_centering_timging(struct display_timing - mode_crt_reg, - struct display_timing panel_crt_reg); - -static int check_lvds_chip(int device_id_subaddr, int device_id) -{ - if (lvds_register_read(device_id_subaddr) == device_id) - return OK; - else - return FAIL; -} - -void __devinit viafb_init_lcd_size(void) -{ - DEBUG_MSG(KERN_INFO "viafb_init_lcd_size()\n"); - - fp_id_to_vindex(viafb_lcd_panel_id); - viaparinfo->lvds_setting_info2->lcd_panel_id = - viaparinfo->lvds_setting_info->lcd_panel_id; - viaparinfo->lvds_setting_info2->lcd_panel_hres = - viaparinfo->lvds_setting_info->lcd_panel_hres; - viaparinfo->lvds_setting_info2->lcd_panel_vres = - viaparinfo->lvds_setting_info->lcd_panel_vres; - viaparinfo->lvds_setting_info2->device_lcd_dualedge = - viaparinfo->lvds_setting_info->device_lcd_dualedge; - viaparinfo->lvds_setting_info2->LCDDithering = - viaparinfo->lvds_setting_info->LCDDithering; -} - -static bool lvds_identify_integratedlvds(void) -{ - if (viafb_display_hardware_layout == HW_LAYOUT_LCD_EXTERNAL_LCD2) { - /* Two dual channel LCD (Internal LVDS + External LVDS): */ - /* If we have an external LVDS, such as VT1636, we should - have its chip ID already. */ - if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { - viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name = - INTEGRATED_LVDS; - DEBUG_MSG(KERN_INFO "Support two dual channel LVDS! " - "(Internal LVDS + External LVDS)\n"); - } else { - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = - INTEGRATED_LVDS; - DEBUG_MSG(KERN_INFO "Not found external LVDS, " - "so can't support two dual channel LVDS!\n"); - } - } else if (viafb_display_hardware_layout == HW_LAYOUT_LCD1_LCD2) { - /* Two single channel LCD (Internal LVDS + Internal LVDS): */ - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = - INTEGRATED_LVDS; - viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name = - INTEGRATED_LVDS; - DEBUG_MSG(KERN_INFO "Support two single channel LVDS! " - "(Internal LVDS + Internal LVDS)\n"); - } else if (viafb_display_hardware_layout != HW_LAYOUT_DVI_ONLY) { - /* If we have found external LVDS, just use it, - otherwise, we will use internal LVDS as default. */ - if (!viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = - INTEGRATED_LVDS; - DEBUG_MSG(KERN_INFO "Found Integrated LVDS!\n"); - } - } else { - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = - NON_LVDS_TRANSMITTER; - DEBUG_MSG(KERN_INFO "Do not support LVDS!\n"); - return false; - } - - return true; -} - -int __devinit viafb_lvds_trasmitter_identify(void) -{ - if (viafb_lvds_identify_vt1636(VIA_PORT_31)) { - viaparinfo->chip_info->lvds_chip_info.i2c_port = VIA_PORT_31; - DEBUG_MSG(KERN_INFO - "Found VIA VT1636 LVDS on port i2c 0x31\n"); - } else { - if (viafb_lvds_identify_vt1636(VIA_PORT_2C)) { - viaparinfo->chip_info->lvds_chip_info.i2c_port = - VIA_PORT_2C; - DEBUG_MSG(KERN_INFO - "Found VIA VT1636 LVDS on port gpio 0x2c\n"); - } - } - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) - lvds_identify_integratedlvds(); - - if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) - return true; - /* Check for VT1631: */ - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = VT1631_LVDS; - viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr = - VT1631_LVDS_I2C_ADDR; - - if (check_lvds_chip(VT1631_DEVICE_ID_REG, VT1631_DEVICE_ID) != FAIL) { - DEBUG_MSG(KERN_INFO "\n VT1631 LVDS ! \n"); - DEBUG_MSG(KERN_INFO "\n %2d", - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name); - DEBUG_MSG(KERN_INFO "\n %2d", - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name); - return OK; - } - - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = - NON_LVDS_TRANSMITTER; - viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr = - VT1631_LVDS_I2C_ADDR; - return FAIL; -} - -static void __devinit fp_id_to_vindex(int panel_id) -{ - DEBUG_MSG(KERN_INFO "fp_get_panel_id()\n"); - - if (panel_id > LCD_PANEL_ID_MAXIMUM) - viafb_lcd_panel_id = panel_id = - viafb_read_reg(VIACR, CR3F) & 0x0F; - - switch (panel_id) { - case 0x0: - viaparinfo->lvds_setting_info->lcd_panel_hres = 640; - viaparinfo->lvds_setting_info->lcd_panel_vres = 480; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID0_640X480; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x1: - viaparinfo->lvds_setting_info->lcd_panel_hres = 800; - viaparinfo->lvds_setting_info->lcd_panel_vres = 600; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID1_800X600; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x2: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID2_1024X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x3: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID3_1280X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x4: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; - viaparinfo->lvds_setting_info->lcd_panel_vres = 1024; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID4_1280X1024; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x5: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1400; - viaparinfo->lvds_setting_info->lcd_panel_vres = 1050; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID5_1400X1050; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x6: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1600; - viaparinfo->lvds_setting_info->lcd_panel_vres = 1200; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID6_1600X1200; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x8: - viaparinfo->lvds_setting_info->lcd_panel_hres = 800; - viaparinfo->lvds_setting_info->lcd_panel_vres = 480; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_IDA_800X480; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x9: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID2_1024X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0xA: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID2_1024X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - case 0xB: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID2_1024X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - case 0xC: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID3_1280X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - case 0xD: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; - viaparinfo->lvds_setting_info->lcd_panel_vres = 1024; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID4_1280X1024; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - case 0xE: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1400; - viaparinfo->lvds_setting_info->lcd_panel_vres = 1050; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID5_1400X1050; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - case 0xF: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1600; - viaparinfo->lvds_setting_info->lcd_panel_vres = 1200; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID6_1600X1200; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - case 0x10: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1366; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID7_1366X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - case 0x11: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; - viaparinfo->lvds_setting_info->lcd_panel_vres = 600; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID8_1024X600; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x12: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID3_1280X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x13: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; - viaparinfo->lvds_setting_info->lcd_panel_vres = 800; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID9_1280X800; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x14: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1360; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_IDB_1360X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - case 0x15: - viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; - viaparinfo->lvds_setting_info->lcd_panel_vres = 768; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID3_1280X768; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - case 0x16: - viaparinfo->lvds_setting_info->lcd_panel_hres = 480; - viaparinfo->lvds_setting_info->lcd_panel_vres = 640; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_IDC_480X640; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 1; - break; - case 0x17: - /* OLPC XO-1.5 panel */ - viaparinfo->lvds_setting_info->lcd_panel_hres = 1200; - viaparinfo->lvds_setting_info->lcd_panel_vres = 900; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_IDD_1200X900; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 0; - break; - default: - viaparinfo->lvds_setting_info->lcd_panel_hres = 800; - viaparinfo->lvds_setting_info->lcd_panel_vres = 600; - viaparinfo->lvds_setting_info->lcd_panel_id = - LCD_PANEL_ID1_800X600; - viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; - viaparinfo->lvds_setting_info->LCDDithering = 1; - } -} - -static int lvds_register_read(int index) -{ - u8 data; - - viafb_i2c_readbyte(VIA_PORT_2C, - (u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr, - (u8) index, &data); - return data; -} - -static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, - int panel_vres) -{ - int reg_value = 0; - int viafb_load_reg_num; - struct io_register *reg = NULL; - - DEBUG_MSG(KERN_INFO "load_lcd_scaling()!!\n"); - - /* LCD Scaling Enable */ - viafb_write_reg_mask(CR79, VIACR, 0x07, BIT0 + BIT1 + BIT2); - - /* Check if expansion for horizontal */ - if (set_hres < panel_hres) { - /* Load Horizontal Scaling Factor */ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CLE266: - case UNICHROME_K400: - reg_value = - CLE266_LCD_HOR_SCF_FORMULA(set_hres, panel_hres); - viafb_load_reg_num = - lcd_scaling_factor_CLE.lcd_hor_scaling_factor. - reg_num; - reg = lcd_scaling_factor_CLE.lcd_hor_scaling_factor.reg; - viafb_load_reg(reg_value, - viafb_load_reg_num, reg, VIACR); - break; - case UNICHROME_K800: - case UNICHROME_PM800: - case UNICHROME_CN700: - case UNICHROME_CX700: - case UNICHROME_K8M890: - case UNICHROME_P4M890: - case UNICHROME_P4M900: - case UNICHROME_CN750: - case UNICHROME_VX800: - case UNICHROME_VX855: - case UNICHROME_VX900: - reg_value = - K800_LCD_HOR_SCF_FORMULA(set_hres, panel_hres); - /* Horizontal scaling enabled */ - viafb_write_reg_mask(CRA2, VIACR, 0xC0, BIT7 + BIT6); - viafb_load_reg_num = - lcd_scaling_factor.lcd_hor_scaling_factor.reg_num; - reg = lcd_scaling_factor.lcd_hor_scaling_factor.reg; - viafb_load_reg(reg_value, - viafb_load_reg_num, reg, VIACR); - break; - } - - DEBUG_MSG(KERN_INFO "Horizontal Scaling value = %d", reg_value); - } else { - /* Horizontal scaling disabled */ - viafb_write_reg_mask(CRA2, VIACR, 0x00, BIT7); - } - - /* Check if expansion for vertical */ - if (set_vres < panel_vres) { - /* Load Vertical Scaling Factor */ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CLE266: - case UNICHROME_K400: - reg_value = - CLE266_LCD_VER_SCF_FORMULA(set_vres, panel_vres); - viafb_load_reg_num = - lcd_scaling_factor_CLE.lcd_ver_scaling_factor. - reg_num; - reg = lcd_scaling_factor_CLE.lcd_ver_scaling_factor.reg; - viafb_load_reg(reg_value, - viafb_load_reg_num, reg, VIACR); - break; - case UNICHROME_K800: - case UNICHROME_PM800: - case UNICHROME_CN700: - case UNICHROME_CX700: - case UNICHROME_K8M890: - case UNICHROME_P4M890: - case UNICHROME_P4M900: - case UNICHROME_CN750: - case UNICHROME_VX800: - case UNICHROME_VX855: - case UNICHROME_VX900: - reg_value = - K800_LCD_VER_SCF_FORMULA(set_vres, panel_vres); - /* Vertical scaling enabled */ - viafb_write_reg_mask(CRA2, VIACR, 0x08, BIT3); - viafb_load_reg_num = - lcd_scaling_factor.lcd_ver_scaling_factor.reg_num; - reg = lcd_scaling_factor.lcd_ver_scaling_factor.reg; - viafb_load_reg(reg_value, - viafb_load_reg_num, reg, VIACR); - break; - } - - DEBUG_MSG(KERN_INFO "Vertical Scaling value = %d", reg_value); - } else { - /* Vertical scaling disabled */ - viafb_write_reg_mask(CRA2, VIACR, 0x00, BIT3); - } -} - -static void via_pitch_alignment_patch_lcd( - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information - *plvds_chip_info) -{ - unsigned char cr13, cr35, cr65, cr66, cr67; - unsigned long dwScreenPitch = 0; - unsigned long dwPitch; - - dwPitch = plvds_setting_info->h_active * (plvds_setting_info->bpp >> 3); - if (dwPitch & 0x1F) { - dwScreenPitch = ((dwPitch + 31) & ~31) >> 3; - if (plvds_setting_info->iga_path == IGA2) { - if (plvds_setting_info->bpp > 8) { - cr66 = (unsigned char)(dwScreenPitch & 0xFF); - viafb_write_reg(CR66, VIACR, cr66); - cr67 = viafb_read_reg(VIACR, CR67) & 0xFC; - cr67 |= - (unsigned - char)((dwScreenPitch & 0x300) >> 8); - viafb_write_reg(CR67, VIACR, cr67); - } - - /* Fetch Count */ - cr67 = viafb_read_reg(VIACR, CR67) & 0xF3; - cr67 |= (unsigned char)((dwScreenPitch & 0x600) >> 7); - viafb_write_reg(CR67, VIACR, cr67); - cr65 = (unsigned char)((dwScreenPitch >> 1) & 0xFF); - cr65 += 2; - viafb_write_reg(CR65, VIACR, cr65); - } else { - if (plvds_setting_info->bpp > 8) { - cr13 = (unsigned char)(dwScreenPitch & 0xFF); - viafb_write_reg(CR13, VIACR, cr13); - cr35 = viafb_read_reg(VIACR, CR35) & 0x1F; - cr35 |= - (unsigned - char)((dwScreenPitch & 0x700) >> 3); - viafb_write_reg(CR35, VIACR, cr35); - } - } - } -} -static void lcd_patch_skew_dvp0(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) { - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_P4M900: - viafb_vt1636_patch_skew_on_vt3364(plvds_setting_info, - plvds_chip_info); - break; - case UNICHROME_P4M890: - viafb_vt1636_patch_skew_on_vt3327(plvds_setting_info, - plvds_chip_info); - break; - } - } -} -static void lcd_patch_skew_dvp1(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) { - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CX700: - viafb_vt1636_patch_skew_on_vt3324(plvds_setting_info, - plvds_chip_info); - break; - } - } -} -static void lcd_patch_skew(struct lvds_setting_information - *plvds_setting_info, struct lvds_chip_information *plvds_chip_info) -{ - DEBUG_MSG(KERN_INFO "lcd_patch_skew\n"); - switch (plvds_chip_info->output_interface) { - case INTERFACE_DVP0: - lcd_patch_skew_dvp0(plvds_setting_info, plvds_chip_info); - break; - case INTERFACE_DVP1: - lcd_patch_skew_dvp1(plvds_setting_info, plvds_chip_info); - break; - case INTERFACE_DFP_LOW: - if (UNICHROME_P4M900 == viaparinfo->chip_info->gfx_chip_name) { - viafb_write_reg_mask(CR99, VIACR, 0x08, - BIT0 + BIT1 + BIT2 + BIT3); - } - break; - } -} - -/* LCD Set Mode */ -void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table, - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - int set_iga = plvds_setting_info->iga_path; - int mode_bpp = plvds_setting_info->bpp; - int set_hres = plvds_setting_info->h_active; - int set_vres = plvds_setting_info->v_active; - int panel_hres = plvds_setting_info->lcd_panel_hres; - int panel_vres = plvds_setting_info->lcd_panel_vres; - u32 pll_D_N; - struct display_timing mode_crt_reg, panel_crt_reg; - struct crt_mode_table *panel_crt_table = NULL; - struct VideoModeTable *vmode_tbl = viafb_get_mode(panel_hres, - panel_vres); - - DEBUG_MSG(KERN_INFO "viafb_lcd_set_mode!!\n"); - /* Get mode table */ - mode_crt_reg = mode_crt_table->crtc; - /* Get panel table Pointer */ - panel_crt_table = vmode_tbl->crtc; - panel_crt_reg = panel_crt_table->crtc; - DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n"); - if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) - viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info); - plvds_setting_info->vclk = panel_crt_table->clk; - if (set_iga == IGA1) { - /* IGA1 doesn't have LCD scaling, so set it as centering. */ - viafb_load_crtc_timing(lcd_centering_timging - (mode_crt_reg, panel_crt_reg), IGA1); - } else { - /* Expansion */ - if (plvds_setting_info->display_method == LCD_EXPANDSION - && (set_hres < panel_hres || set_vres < panel_vres)) { - /* expansion timing IGA2 loaded panel set timing*/ - viafb_load_crtc_timing(panel_crt_reg, IGA2); - DEBUG_MSG(KERN_INFO "viafb_load_crtc_timing!!\n"); - load_lcd_scaling(set_hres, set_vres, panel_hres, - panel_vres); - DEBUG_MSG(KERN_INFO "load_lcd_scaling!!\n"); - } else { /* Centering */ - /* centering timing IGA2 always loaded panel - and mode releative timing */ - viafb_load_crtc_timing(lcd_centering_timging - (mode_crt_reg, panel_crt_reg), IGA2); - viafb_write_reg_mask(CR79, VIACR, 0x00, - BIT0 + BIT1 + BIT2); - /* LCD scaling disabled */ - } - } - - /* Fetch count for IGA2 only */ - viafb_load_fetch_count_reg(set_hres, mode_bpp / 8, set_iga); - - if ((viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266) - && (viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400)) - viafb_load_FIFO_reg(set_iga, set_hres, set_vres); - - fill_lcd_format(); - - pll_D_N = viafb_get_clk_value(panel_crt_table[0].clk); - DEBUG_MSG(KERN_INFO "PLL=0x%x", pll_D_N); - viafb_set_vclock(pll_D_N, set_iga); - lcd_patch_skew(plvds_setting_info, plvds_chip_info); - - /* If K8M800, enable LCD Prefetch Mode. */ - if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) - || (UNICHROME_K8M890 == viaparinfo->chip_info->gfx_chip_name)) - viafb_write_reg_mask(CR6A, VIACR, 0x01, BIT0); - - /* Patch for non 32bit alignment mode */ - via_pitch_alignment_patch_lcd(plvds_setting_info, plvds_chip_info); -} - -static void integrated_lvds_disable(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - bool turn_off_first_powersequence = false; - bool turn_off_second_powersequence = false; - if (INTERFACE_LVDS0LVDS1 == plvds_chip_info->output_interface) - turn_off_first_powersequence = true; - if (INTERFACE_LVDS0 == plvds_chip_info->output_interface) - turn_off_first_powersequence = true; - if (INTERFACE_LVDS1 == plvds_chip_info->output_interface) - turn_off_second_powersequence = true; - if (turn_off_second_powersequence) { - /* Use second power sequence control: */ - - /* Turn off power sequence. */ - viafb_write_reg_mask(CRD4, VIACR, 0, BIT1); - - /* Turn off back light. */ - viafb_write_reg_mask(CRD3, VIACR, 0xC0, BIT6 + BIT7); - } - if (turn_off_first_powersequence) { - /* Use first power sequence control: */ - - /* Turn off power sequence. */ - viafb_write_reg_mask(CR6A, VIACR, 0, BIT3); - - /* Turn off back light. */ - viafb_write_reg_mask(CR91, VIACR, 0xC0, BIT6 + BIT7); - } - - /* Power off LVDS channel. */ - switch (plvds_chip_info->output_interface) { - case INTERFACE_LVDS0: - { - viafb_write_reg_mask(CRD2, VIACR, 0x80, BIT7); - break; - } - - case INTERFACE_LVDS1: - { - viafb_write_reg_mask(CRD2, VIACR, 0x40, BIT6); - break; - } - - case INTERFACE_LVDS0LVDS1: - { - viafb_write_reg_mask(CRD2, VIACR, 0xC0, BIT6 + BIT7); - break; - } - } -} - -static void integrated_lvds_enable(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - DEBUG_MSG(KERN_INFO "integrated_lvds_enable, out_interface:%d\n", - plvds_chip_info->output_interface); - if (plvds_setting_info->lcd_mode == LCD_SPWG) - viafb_write_reg_mask(CRD2, VIACR, 0x00, BIT0 + BIT1); - else - viafb_write_reg_mask(CRD2, VIACR, 0x03, BIT0 + BIT1); - - switch (plvds_chip_info->output_interface) { - case INTERFACE_LVDS0LVDS1: - case INTERFACE_LVDS0: - /* Use first power sequence control: */ - /* Use hardware control power sequence. */ - viafb_write_reg_mask(CR91, VIACR, 0, BIT0); - /* Turn on back light. */ - viafb_write_reg_mask(CR91, VIACR, 0, BIT6 + BIT7); - /* Turn on hardware power sequence. */ - viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3); - break; - case INTERFACE_LVDS1: - /* Use second power sequence control: */ - /* Use hardware control power sequence. */ - viafb_write_reg_mask(CRD3, VIACR, 0, BIT0); - /* Turn on back light. */ - viafb_write_reg_mask(CRD3, VIACR, 0, BIT6 + BIT7); - /* Turn on hardware power sequence. */ - viafb_write_reg_mask(CRD4, VIACR, 0x02, BIT1); - break; - } - - /* Power on LVDS channel. */ - switch (plvds_chip_info->output_interface) { - case INTERFACE_LVDS0: - { - viafb_write_reg_mask(CRD2, VIACR, 0, BIT7); - break; - } - - case INTERFACE_LVDS1: - { - viafb_write_reg_mask(CRD2, VIACR, 0, BIT6); - break; - } - - case INTERFACE_LVDS0LVDS1: - { - viafb_write_reg_mask(CRD2, VIACR, 0, BIT6 + BIT7); - break; - } - } -} - -void viafb_lcd_disable(void) -{ - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { - lcd_powersequence_off(); - /* DI1 pad off */ - viafb_write_reg_mask(SR1E, VIASR, 0x00, 0x30); - } else if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) { - if (viafb_LCD2_ON - && (INTEGRATED_LVDS == - viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name)) - integrated_lvds_disable(viaparinfo->lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info2); - if (INTEGRATED_LVDS == - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) - integrated_lvds_disable(viaparinfo->lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info); - if (VT1636_LVDS == viaparinfo->chip_info-> - lvds_chip_info.lvds_chip_name) - viafb_disable_lvds_vt1636(viaparinfo->lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info); - } else if (VT1636_LVDS == - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { - viafb_disable_lvds_vt1636(viaparinfo->lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info); - } else { - /* Backlight off */ - viafb_write_reg_mask(SR3D, VIASR, 0x00, 0x20); - /* 24 bit DI data paht off */ - viafb_write_reg_mask(CR91, VIACR, 0x80, 0x80); - } - - /* Disable expansion bit */ - viafb_write_reg_mask(CR79, VIACR, 0x00, 0x01); - /* Simultaneout disabled */ - viafb_write_reg_mask(CR6B, VIACR, 0x00, 0x08); -} - -static void set_lcd_output_path(int set_iga, int output_interface) -{ - switch (output_interface) { - case INTERFACE_DFP: - if ((UNICHROME_K8M890 == viaparinfo->chip_info->gfx_chip_name) - || (UNICHROME_P4M890 == - viaparinfo->chip_info->gfx_chip_name)) - viafb_write_reg_mask(CR97, VIACR, 0x84, - BIT7 + BIT2 + BIT1 + BIT0); - case INTERFACE_DVP0: - case INTERFACE_DVP1: - case INTERFACE_DFP_HIGH: - case INTERFACE_DFP_LOW: - if (set_iga == IGA2) - viafb_write_reg(CR91, VIACR, 0x00); - break; - } -} - -void viafb_lcd_enable(void) -{ - viafb_write_reg_mask(CR6B, VIACR, 0x00, BIT3); - viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3); - set_lcd_output_path(viaparinfo->lvds_setting_info->iga_path, - viaparinfo->chip_info->lvds_chip_info.output_interface); - if (viafb_LCD2_ON) - set_lcd_output_path(viaparinfo->lvds_setting_info2->iga_path, - viaparinfo->chip_info-> - lvds_chip_info2.output_interface); - - if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { - /* DI1 pad on */ - viafb_write_reg_mask(SR1E, VIASR, 0x30, 0x30); - lcd_powersequence_on(); - } else if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) { - if (viafb_LCD2_ON && (INTEGRATED_LVDS == - viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name)) - integrated_lvds_enable(viaparinfo->lvds_setting_info2, \ - &viaparinfo->chip_info->lvds_chip_info2); - if (INTEGRATED_LVDS == - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) - integrated_lvds_enable(viaparinfo->lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info); - if (VT1636_LVDS == viaparinfo->chip_info-> - lvds_chip_info.lvds_chip_name) - viafb_enable_lvds_vt1636(viaparinfo-> - lvds_setting_info, &viaparinfo->chip_info-> - lvds_chip_info); - } else if (VT1636_LVDS == - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { - viafb_enable_lvds_vt1636(viaparinfo->lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info); - } else { - /* Backlight on */ - viafb_write_reg_mask(SR3D, VIASR, 0x20, 0x20); - /* 24 bit DI data paht on */ - viafb_write_reg_mask(CR91, VIACR, 0x00, 0x80); - /* LCD enabled */ - viafb_write_reg_mask(CR6A, VIACR, 0x48, 0x48); - } -} - -static void lcd_powersequence_off(void) -{ - int i, mask, data; - - /* Software control power sequence */ - viafb_write_reg_mask(CR91, VIACR, 0x11, 0x11); - - for (i = 0; i < 3; i++) { - mask = PowerSequenceOff[0][i]; - data = PowerSequenceOff[1][i] & mask; - viafb_write_reg_mask(CR91, VIACR, (u8) data, (u8) mask); - udelay(PowerSequenceOff[2][i]); - } - - /* Disable LCD */ - viafb_write_reg_mask(CR6A, VIACR, 0x00, 0x08); -} - -static void lcd_powersequence_on(void) -{ - int i, mask, data; - - /* Software control power sequence */ - viafb_write_reg_mask(CR91, VIACR, 0x11, 0x11); - - /* Enable LCD */ - viafb_write_reg_mask(CR6A, VIACR, 0x08, 0x08); - - for (i = 0; i < 3; i++) { - mask = PowerSequenceOn[0][i]; - data = PowerSequenceOn[1][i] & mask; - viafb_write_reg_mask(CR91, VIACR, (u8) data, (u8) mask); - udelay(PowerSequenceOn[2][i]); - } - - udelay(1); -} - -static void fill_lcd_format(void) -{ - u8 bdithering = 0, bdual = 0; - - if (viaparinfo->lvds_setting_info->device_lcd_dualedge) - bdual = BIT4; - if (viaparinfo->lvds_setting_info->LCDDithering) - bdithering = BIT0; - /* Dual & Dithering */ - viafb_write_reg_mask(CR88, VIACR, (bdithering | bdual), BIT4 + BIT0); -} - -static void check_diport_of_integrated_lvds( - struct lvds_chip_information *plvds_chip_info, - struct lvds_setting_information - *plvds_setting_info) -{ - /* Determine LCD DI Port by hardware layout. */ - switch (viafb_display_hardware_layout) { - case HW_LAYOUT_LCD_ONLY: - { - if (plvds_setting_info->device_lcd_dualedge) { - plvds_chip_info->output_interface = - INTERFACE_LVDS0LVDS1; - } else { - plvds_chip_info->output_interface = - INTERFACE_LVDS0; - } - - break; - } - - case HW_LAYOUT_DVI_ONLY: - { - plvds_chip_info->output_interface = INTERFACE_NONE; - break; - } - - case HW_LAYOUT_LCD1_LCD2: - case HW_LAYOUT_LCD_EXTERNAL_LCD2: - { - plvds_chip_info->output_interface = - INTERFACE_LVDS0LVDS1; - break; - } - - case HW_LAYOUT_LCD_DVI: - { - plvds_chip_info->output_interface = INTERFACE_LVDS1; - break; - } - - default: - { - plvds_chip_info->output_interface = INTERFACE_LVDS1; - break; - } - } - - DEBUG_MSG(KERN_INFO - "Display Hardware Layout: 0x%x, LCD DI Port: 0x%x\n", - viafb_display_hardware_layout, - plvds_chip_info->output_interface); -} - -void __devinit viafb_init_lvds_output_interface(struct lvds_chip_information - *plvds_chip_info, - struct lvds_setting_information - *plvds_setting_info) -{ - if (INTERFACE_NONE != plvds_chip_info->output_interface) { - /*Do nothing, lcd port is specified by module parameter */ - return; - } - - switch (plvds_chip_info->lvds_chip_name) { - - case VT1636_LVDS: - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CX700: - plvds_chip_info->output_interface = INTERFACE_DVP1; - break; - case UNICHROME_CN700: - plvds_chip_info->output_interface = INTERFACE_DFP_LOW; - break; - default: - plvds_chip_info->output_interface = INTERFACE_DVP0; - break; - } - break; - - case INTEGRATED_LVDS: - check_diport_of_integrated_lvds(plvds_chip_info, - plvds_setting_info); - break; - - default: - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_K8M890: - case UNICHROME_P4M900: - case UNICHROME_P4M890: - plvds_chip_info->output_interface = INTERFACE_DFP_LOW; - break; - default: - plvds_chip_info->output_interface = INTERFACE_DFP; - break; - } - break; - } -} - -static struct display_timing lcd_centering_timging(struct display_timing - mode_crt_reg, - struct display_timing panel_crt_reg) -{ - struct display_timing crt_reg; - - crt_reg.hor_total = panel_crt_reg.hor_total; - crt_reg.hor_addr = mode_crt_reg.hor_addr; - crt_reg.hor_blank_start = - (panel_crt_reg.hor_addr - mode_crt_reg.hor_addr) / 2 + - crt_reg.hor_addr; - crt_reg.hor_blank_end = panel_crt_reg.hor_blank_end; - crt_reg.hor_sync_start = - (panel_crt_reg.hor_sync_start - - panel_crt_reg.hor_blank_start) + crt_reg.hor_blank_start; - crt_reg.hor_sync_end = panel_crt_reg.hor_sync_end; - - crt_reg.ver_total = panel_crt_reg.ver_total; - crt_reg.ver_addr = mode_crt_reg.ver_addr; - crt_reg.ver_blank_start = - (panel_crt_reg.ver_addr - mode_crt_reg.ver_addr) / 2 + - crt_reg.ver_addr; - crt_reg.ver_blank_end = panel_crt_reg.ver_blank_end; - crt_reg.ver_sync_start = - (panel_crt_reg.ver_sync_start - - panel_crt_reg.ver_blank_start) + crt_reg.ver_blank_start; - crt_reg.ver_sync_end = panel_crt_reg.ver_sync_end; - - return crt_reg; -} - -bool viafb_lcd_get_mobile_state(bool *mobile) -{ - unsigned char *romptr, *tableptr; - u8 core_base; - unsigned char *biosptr; - /* Rom address */ - u32 romaddr = 0x000C0000; - u16 start_pattern = 0; - - biosptr = ioremap(romaddr, 0x10000); - - memcpy(&start_pattern, biosptr, 2); - /* Compare pattern */ - if (start_pattern == 0xAA55) { - /* Get the start of Table */ - /* 0x1B means BIOS offset position */ - romptr = biosptr + 0x1B; - tableptr = biosptr + *((u16 *) romptr); - - /* Get the start of biosver structure */ - /* 18 means BIOS version position. */ - romptr = tableptr + 18; - romptr = biosptr + *((u16 *) romptr); - - /* The offset should be 44, but the - actual image is less three char. */ - /* pRom += 44; */ - romptr += 41; - - core_base = *romptr++; - - if (core_base & 0x8) - *mobile = false; - else - *mobile = true; - /* release memory */ - iounmap(biosptr); - - return true; - } else { - iounmap(biosptr); - return false; - } -} diff --git a/drivers/video/via/lcd.h b/drivers/video/via/lcd.h deleted file mode 100644 index c7909fe2955..00000000000 --- a/drivers/video/via/lcd.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 __LCD_H__ -#define __LCD_H__ - -/*Definition TMDS Device ID register*/ -#define VT1631_DEVICE_ID_REG 0x02 -#define VT1631_DEVICE_ID 0x92 - -#define VT3271_DEVICE_ID_REG 0x02 -#define VT3271_DEVICE_ID 0x71 - -/* Definition DVI Panel ID*/ -/* Resolution: 640x480, Channel: single, Dithering: Enable */ -#define LCD_PANEL_ID0_640X480 0x00 -/* Resolution: 800x600, Channel: single, Dithering: Enable */ -#define LCD_PANEL_ID1_800X600 0x01 -/* Resolution: 1024x768, Channel: single, Dithering: Enable */ -#define LCD_PANEL_ID2_1024X768 0x02 -/* Resolution: 1280x768, Channel: single, Dithering: Enable */ -#define LCD_PANEL_ID3_1280X768 0x03 -/* Resolution: 1280x1024, Channel: dual, Dithering: Enable */ -#define LCD_PANEL_ID4_1280X1024 0x04 -/* Resolution: 1400x1050, Channel: dual, Dithering: Enable */ -#define LCD_PANEL_ID5_1400X1050 0x05 -/* Resolution: 1600x1200, Channel: dual, Dithering: Enable */ -#define LCD_PANEL_ID6_1600X1200 0x06 -/* Resolution: 1366x768, Channel: single, Dithering: Disable */ -#define LCD_PANEL_ID7_1366X768 0x07 -/* Resolution: 1024x600, Channel: single, Dithering: Enable*/ -#define LCD_PANEL_ID8_1024X600 0x08 -/* Resolution: 1280x800, Channel: single, Dithering: Enable*/ -#define LCD_PANEL_ID9_1280X800 0x09 -/* Resolution: 800x480, Channel: single, Dithering: Enable*/ -#define LCD_PANEL_IDA_800X480 0x0A -/* Resolution: 1360x768, Channel: single, Dithering: Disable*/ -#define LCD_PANEL_IDB_1360X768 0x0B -/* Resolution: 480x640, Channel: single, Dithering: Enable */ -#define LCD_PANEL_IDC_480X640 0x0C -/* Resolution: 1200x900, Channel: single, Dithering: Disable */ -#define LCD_PANEL_IDD_1200X900 0x0D - - -extern int viafb_LCD2_ON; -extern int viafb_LCD_ON; -extern int viafb_DVI_ON; - -void viafb_disable_lvds_vt1636(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -void viafb_enable_lvds_vt1636(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -void viafb_lcd_disable(void); -void viafb_lcd_enable(void); -void __devinit viafb_init_lcd_size(void); -void __devinit viafb_init_lvds_output_interface(struct lvds_chip_information - *plvds_chip_info, - struct lvds_setting_information - *plvds_setting_info); -void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table, - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -int __devinit viafb_lvds_trasmitter_identify(void); -void viafb_init_lvds_output_interface(struct lvds_chip_information - *plvds_chip_info, - struct lvds_setting_information - *plvds_setting_info); -bool viafb_lcd_get_mobile_state(bool *mobile); -void viafb_load_crtc_timing(struct display_timing device_timing, - int set_iga); - -#endif /* __LCD_H__ */ diff --git a/drivers/video/via/share.h b/drivers/video/via/share.h deleted file mode 100644 index 2cbe1031b42..00000000000 --- a/drivers/video/via/share.h +++ /dev/null @@ -1,838 +0,0 @@ -/* - * 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 __SHARE_H__ -#define __SHARE_H__ - -/* Define Return Value */ -#define FAIL -1 -#define OK 1 - -#ifndef NULL -#define NULL 0 -#endif - -/* Define Bit Field */ -#define BIT0 0x01 -#define BIT1 0x02 -#define BIT2 0x04 -#define BIT3 0x08 -#define BIT4 0x10 -#define BIT5 0x20 -#define BIT6 0x40 -#define BIT7 0x80 - -/* Video Memory Size */ -#define VIDEO_MEMORY_SIZE_16M 0x1000000 - -/* - * Lengths of the VPIT structure arrays. - */ -#define StdCR 0x19 -#define StdSR 0x04 -#define StdGR 0x09 -#define StdAR 0x14 - -#define PatchCR 11 - -/* Display path */ -#define IGA1 1 -#define IGA2 2 - -/* Define Color Depth */ -#define MODE_8BPP 1 -#define MODE_16BPP 2 -#define MODE_32BPP 4 - -#define GR20 0x20 -#define GR21 0x21 -#define GR22 0x22 - -/* Sequencer Registers */ -#define SR01 0x01 -#define SR10 0x10 -#define SR12 0x12 -#define SR15 0x15 -#define SR16 0x16 -#define SR17 0x17 -#define SR18 0x18 -#define SR1B 0x1B -#define SR1A 0x1A -#define SR1C 0x1C -#define SR1D 0x1D -#define SR1E 0x1E -#define SR1F 0x1F -#define SR20 0x20 -#define SR21 0x21 -#define SR22 0x22 -#define SR2A 0x2A -#define SR2D 0x2D -#define SR2E 0x2E - -#define SR30 0x30 -#define SR39 0x39 -#define SR3D 0x3D -#define SR3E 0x3E -#define SR3F 0x3F -#define SR40 0x40 -#define SR43 0x43 -#define SR44 0x44 -#define SR45 0x45 -#define SR46 0x46 -#define SR47 0x47 -#define SR48 0x48 -#define SR49 0x49 -#define SR4A 0x4A -#define SR4B 0x4B -#define SR4C 0x4C -#define SR52 0x52 -#define SR57 0x57 -#define SR58 0x58 -#define SR59 0x59 -#define SR5D 0x5D -#define SR5E 0x5E -#define SR65 0x65 - -/* CRT Controller Registers */ -#define CR00 0x00 -#define CR01 0x01 -#define CR02 0x02 -#define CR03 0x03 -#define CR04 0x04 -#define CR05 0x05 -#define CR06 0x06 -#define CR07 0x07 -#define CR08 0x08 -#define CR09 0x09 -#define CR0A 0x0A -#define CR0B 0x0B -#define CR0C 0x0C -#define CR0D 0x0D -#define CR0E 0x0E -#define CR0F 0x0F -#define CR10 0x10 -#define CR11 0x11 -#define CR12 0x12 -#define CR13 0x13 -#define CR14 0x14 -#define CR15 0x15 -#define CR16 0x16 -#define CR17 0x17 -#define CR18 0x18 - -/* Extend CRT Controller Registers */ -#define CR30 0x30 -#define CR31 0x31 -#define CR32 0x32 -#define CR33 0x33 -#define CR34 0x34 -#define CR35 0x35 -#define CR36 0x36 -#define CR37 0x37 -#define CR38 0x38 -#define CR39 0x39 -#define CR3A 0x3A -#define CR3B 0x3B -#define CR3C 0x3C -#define CR3D 0x3D -#define CR3E 0x3E -#define CR3F 0x3F -#define CR40 0x40 -#define CR41 0x41 -#define CR42 0x42 -#define CR43 0x43 -#define CR44 0x44 -#define CR45 0x45 -#define CR46 0x46 -#define CR47 0x47 -#define CR48 0x48 -#define CR49 0x49 -#define CR4A 0x4A -#define CR4B 0x4B -#define CR4C 0x4C -#define CR4D 0x4D -#define CR4E 0x4E -#define CR4F 0x4F -#define CR50 0x50 -#define CR51 0x51 -#define CR52 0x52 -#define CR53 0x53 -#define CR54 0x54 -#define CR55 0x55 -#define CR56 0x56 -#define CR57 0x57 -#define CR58 0x58 -#define CR59 0x59 -#define CR5A 0x5A -#define CR5B 0x5B -#define CR5C 0x5C -#define CR5D 0x5D -#define CR5E 0x5E -#define CR5F 0x5F -#define CR60 0x60 -#define CR61 0x61 -#define CR62 0x62 -#define CR63 0x63 -#define CR64 0x64 -#define CR65 0x65 -#define CR66 0x66 -#define CR67 0x67 -#define CR68 0x68 -#define CR69 0x69 -#define CR6A 0x6A -#define CR6B 0x6B -#define CR6C 0x6C -#define CR6D 0x6D -#define CR6E 0x6E -#define CR6F 0x6F -#define CR70 0x70 -#define CR71 0x71 -#define CR72 0x72 -#define CR73 0x73 -#define CR74 0x74 -#define CR75 0x75 -#define CR76 0x76 -#define CR77 0x77 -#define CR78 0x78 -#define CR79 0x79 -#define CR7A 0x7A -#define CR7B 0x7B -#define CR7C 0x7C -#define CR7D 0x7D -#define CR7E 0x7E -#define CR7F 0x7F -#define CR80 0x80 -#define CR81 0x81 -#define CR82 0x82 -#define CR83 0x83 -#define CR84 0x84 -#define CR85 0x85 -#define CR86 0x86 -#define CR87 0x87 -#define CR88 0x88 -#define CR89 0x89 -#define CR8A 0x8A -#define CR8B 0x8B -#define CR8C 0x8C -#define CR8D 0x8D -#define CR8E 0x8E -#define CR8F 0x8F -#define CR90 0x90 -#define CR91 0x91 -#define CR92 0x92 -#define CR93 0x93 -#define CR94 0x94 -#define CR95 0x95 -#define CR96 0x96 -#define CR97 0x97 -#define CR98 0x98 -#define CR99 0x99 -#define CR9A 0x9A -#define CR9B 0x9B -#define CR9C 0x9C -#define CR9D 0x9D -#define CR9E 0x9E -#define CR9F 0x9F -#define CRA0 0xA0 -#define CRA1 0xA1 -#define CRA2 0xA2 -#define CRA3 0xA3 -#define CRD2 0xD2 -#define CRD3 0xD3 -#define CRD4 0xD4 - -/* LUT Table*/ -#define LUT_DATA 0x3C9 /* DACDATA */ -#define LUT_INDEX_READ 0x3C7 /* DACRX */ -#define LUT_INDEX_WRITE 0x3C8 /* DACWX */ -#define DACMASK 0x3C6 - -/* Definition Device */ -#define DEVICE_CRT 0x01 -#define DEVICE_DVI 0x03 -#define DEVICE_LCD 0x04 - -/* Device output interface */ -#define INTERFACE_NONE 0x00 -#define INTERFACE_ANALOG_RGB 0x01 -#define INTERFACE_DVP0 0x02 -#define INTERFACE_DVP1 0x03 -#define INTERFACE_DFP_HIGH 0x04 -#define INTERFACE_DFP_LOW 0x05 -#define INTERFACE_DFP 0x06 -#define INTERFACE_LVDS0 0x07 -#define INTERFACE_LVDS1 0x08 -#define INTERFACE_LVDS0LVDS1 0x09 -#define INTERFACE_TMDS 0x0A - -#define HW_LAYOUT_LCD_ONLY 0x01 -#define HW_LAYOUT_DVI_ONLY 0x02 -#define HW_LAYOUT_LCD_DVI 0x03 -#define HW_LAYOUT_LCD1_LCD2 0x04 -#define HW_LAYOUT_LCD_EXTERNAL_LCD2 0x10 - -/* Definition Refresh Rate */ -#define REFRESH_50 50 -#define REFRESH_60 60 -#define REFRESH_75 75 -#define REFRESH_85 85 -#define REFRESH_100 100 -#define REFRESH_120 120 - -/* Definition Sync Polarity*/ -#define NEGATIVE 1 -#define POSITIVE 0 - -/*480x640@60 Sync Polarity (GTF) -*/ -#define M480X640_R60_HSP NEGATIVE -#define M480X640_R60_VSP POSITIVE - -/*640x480@60 Sync Polarity (VESA Mode) -*/ -#define M640X480_R60_HSP NEGATIVE -#define M640X480_R60_VSP NEGATIVE - -/*640x480@75 Sync Polarity (VESA Mode) -*/ -#define M640X480_R75_HSP NEGATIVE -#define M640X480_R75_VSP NEGATIVE - -/*640x480@85 Sync Polarity (VESA Mode) -*/ -#define M640X480_R85_HSP NEGATIVE -#define M640X480_R85_VSP NEGATIVE - -/*640x480@100 Sync Polarity (GTF Mode) -*/ -#define M640X480_R100_HSP NEGATIVE -#define M640X480_R100_VSP POSITIVE - -/*640x480@120 Sync Polarity (GTF Mode) -*/ -#define M640X480_R120_HSP NEGATIVE -#define M640X480_R120_VSP POSITIVE - -/*720x480@60 Sync Polarity (GTF Mode) -*/ -#define M720X480_R60_HSP NEGATIVE -#define M720X480_R60_VSP POSITIVE - -/*720x576@60 Sync Polarity (GTF Mode) -*/ -#define M720X576_R60_HSP NEGATIVE -#define M720X576_R60_VSP POSITIVE - -/*800x600@60 Sync Polarity (VESA Mode) -*/ -#define M800X600_R60_HSP POSITIVE -#define M800X600_R60_VSP POSITIVE - -/*800x600@75 Sync Polarity (VESA Mode) -*/ -#define M800X600_R75_HSP POSITIVE -#define M800X600_R75_VSP POSITIVE - -/*800x600@85 Sync Polarity (VESA Mode) -*/ -#define M800X600_R85_HSP POSITIVE -#define M800X600_R85_VSP POSITIVE - -/*800x600@100 Sync Polarity (GTF Mode) -*/ -#define M800X600_R100_HSP NEGATIVE -#define M800X600_R100_VSP POSITIVE - -/*800x600@120 Sync Polarity (GTF Mode) -*/ -#define M800X600_R120_HSP NEGATIVE -#define M800X600_R120_VSP POSITIVE - -/*800x480@60 Sync Polarity (CVT Mode) -*/ -#define M800X480_R60_HSP NEGATIVE -#define M800X480_R60_VSP POSITIVE - -/*848x480@60 Sync Polarity (CVT Mode) -*/ -#define M848X480_R60_HSP NEGATIVE -#define M848X480_R60_VSP POSITIVE - -/*852x480@60 Sync Polarity (GTF Mode) -*/ -#define M852X480_R60_HSP NEGATIVE -#define M852X480_R60_VSP POSITIVE - -/*1024x512@60 Sync Polarity (GTF Mode) -*/ -#define M1024X512_R60_HSP NEGATIVE -#define M1024X512_R60_VSP POSITIVE - -/*1024x600@60 Sync Polarity (GTF Mode) -*/ -#define M1024X600_R60_HSP NEGATIVE -#define M1024X600_R60_VSP POSITIVE - -/*1024x768@60 Sync Polarity (VESA Mode) -*/ -#define M1024X768_R60_HSP NEGATIVE -#define M1024X768_R60_VSP NEGATIVE - -/*1024x768@75 Sync Polarity (VESA Mode) -*/ -#define M1024X768_R75_HSP POSITIVE -#define M1024X768_R75_VSP POSITIVE - -/*1024x768@85 Sync Polarity (VESA Mode) -*/ -#define M1024X768_R85_HSP POSITIVE -#define M1024X768_R85_VSP POSITIVE - -/*1024x768@100 Sync Polarity (GTF Mode) -*/ -#define M1024X768_R100_HSP NEGATIVE -#define M1024X768_R100_VSP POSITIVE - -/*1152x864@75 Sync Polarity (VESA Mode) -*/ -#define M1152X864_R75_HSP POSITIVE -#define M1152X864_R75_VSP POSITIVE - -/*1280x720@60 Sync Polarity (GTF Mode) -*/ -#define M1280X720_R60_HSP NEGATIVE -#define M1280X720_R60_VSP POSITIVE - -/* 1280x768@50 Sync Polarity (GTF Mode) */ -#define M1280X768_R50_HSP NEGATIVE -#define M1280X768_R50_VSP POSITIVE - -/*1280x768@60 Sync Polarity (GTF Mode) -*/ -#define M1280X768_R60_HSP NEGATIVE -#define M1280X768_R60_VSP POSITIVE - -/*1280x800@60 Sync Polarity (CVT Mode) -*/ -#define M1280X800_R60_HSP NEGATIVE -#define M1280X800_R60_VSP POSITIVE - -/*1280x960@60 Sync Polarity (VESA Mode) -*/ -#define M1280X960_R60_HSP POSITIVE -#define M1280X960_R60_VSP POSITIVE - -/*1280x1024@60 Sync Polarity (VESA Mode) -*/ -#define M1280X1024_R60_HSP POSITIVE -#define M1280X1024_R60_VSP POSITIVE - -/* 1360x768@60 Sync Polarity (CVT Mode) */ -#define M1360X768_R60_HSP POSITIVE -#define M1360X768_R60_VSP POSITIVE - -/* 1360x768@60 Sync Polarity (CVT Reduce Blanking Mode) */ -#define M1360X768_RB_R60_HSP POSITIVE -#define M1360X768_RB_R60_VSP NEGATIVE - -/* 1368x768@50 Sync Polarity (GTF Mode) */ -#define M1368X768_R50_HSP NEGATIVE -#define M1368X768_R50_VSP POSITIVE - -/* 1368x768@60 Sync Polarity (VESA Mode) */ -#define M1368X768_R60_HSP NEGATIVE -#define M1368X768_R60_VSP POSITIVE - -/*1280x1024@75 Sync Polarity (VESA Mode) -*/ -#define M1280X1024_R75_HSP POSITIVE -#define M1280X1024_R75_VSP POSITIVE - -/*1280x1024@85 Sync Polarity (VESA Mode) -*/ -#define M1280X1024_R85_HSP POSITIVE -#define M1280X1024_R85_VSP POSITIVE - -/*1440x1050@60 Sync Polarity (GTF Mode) -*/ -#define M1440X1050_R60_HSP NEGATIVE -#define M1440X1050_R60_VSP POSITIVE - -/*1600x1200@60 Sync Polarity (VESA Mode) -*/ -#define M1600X1200_R60_HSP POSITIVE -#define M1600X1200_R60_VSP POSITIVE - -/*1600x1200@75 Sync Polarity (VESA Mode) -*/ -#define M1600X1200_R75_HSP POSITIVE -#define M1600X1200_R75_VSP POSITIVE - -/* 1680x1050@60 Sync Polarity (CVT Mode) */ -#define M1680x1050_R60_HSP NEGATIVE -#define M1680x1050_R60_VSP NEGATIVE - -/* 1680x1050@60 Sync Polarity (CVT Reduce Blanking Mode) */ -#define M1680x1050_RB_R60_HSP POSITIVE -#define M1680x1050_RB_R60_VSP NEGATIVE - -/* 1680x1050@75 Sync Polarity (CVT Mode) */ -#define M1680x1050_R75_HSP NEGATIVE -#define M1680x1050_R75_VSP POSITIVE - -/*1920x1080@60 Sync Polarity (CVT Mode) -*/ -#define M1920X1080_R60_HSP NEGATIVE -#define M1920X1080_R60_VSP POSITIVE - -/* 1920x1080@60 Sync Polarity (CVT Reduce Blanking Mode) */ -#define M1920X1080_RB_R60_HSP POSITIVE -#define M1920X1080_RB_R60_VSP NEGATIVE - -/*1920x1440@60 Sync Polarity (VESA Mode) -*/ -#define M1920X1440_R60_HSP NEGATIVE -#define M1920X1440_R60_VSP POSITIVE - -/*1920x1440@75 Sync Polarity (VESA Mode) -*/ -#define M1920X1440_R75_HSP NEGATIVE -#define M1920X1440_R75_VSP POSITIVE - -#if 0 -/* 1400x1050@60 Sync Polarity (VESA Mode) */ -#define M1400X1050_R60_HSP NEGATIVE -#define M1400X1050_R60_VSP NEGATIVE -#endif - -/* 1400x1050@60 Sync Polarity (CVT Mode) */ -#define M1400X1050_R60_HSP NEGATIVE -#define M1400X1050_R60_VSP POSITIVE - -/* 1400x1050@60 Sync Polarity (CVT Reduce Blanking Mode) */ -#define M1400X1050_RB_R60_HSP POSITIVE -#define M1400X1050_RB_R60_VSP NEGATIVE - -/* 1400x1050@75 Sync Polarity (CVT Mode) */ -#define M1400X1050_R75_HSP NEGATIVE -#define M1400X1050_R75_VSP POSITIVE - -/* 960x600@60 Sync Polarity (CVT Mode) */ -#define M960X600_R60_HSP NEGATIVE -#define M960X600_R60_VSP POSITIVE - -/* 1000x600@60 Sync Polarity (GTF Mode) */ -#define M1000X600_R60_HSP NEGATIVE -#define M1000X600_R60_VSP POSITIVE - -/* 1024x576@60 Sync Polarity (GTF Mode) */ -#define M1024X576_R60_HSP NEGATIVE -#define M1024X576_R60_VSP POSITIVE - -/*1024x600@60 Sync Polarity (GTF Mode)*/ -#define M1024X600_R60_HSP NEGATIVE -#define M1024X600_R60_VSP POSITIVE - -/* 1088x612@60 Sync Polarity (CVT Mode) */ -#define M1088X612_R60_HSP NEGATIVE -#define M1088X612_R60_VSP POSITIVE - -/* 1152x720@60 Sync Polarity (CVT Mode) */ -#define M1152X720_R60_HSP NEGATIVE -#define M1152X720_R60_VSP POSITIVE - -/* 1200x720@60 Sync Polarity (GTF Mode) */ -#define M1200X720_R60_HSP NEGATIVE -#define M1200X720_R60_VSP POSITIVE - -/* 1200x900@60 Sync Polarity (DCON) */ -#define M1200X900_R60_HSP NEGATIVE -#define M1200X900_R60_VSP NEGATIVE - -/* 1280x600@60 Sync Polarity (GTF Mode) */ -#define M1280x600_R60_HSP NEGATIVE -#define M1280x600_R60_VSP POSITIVE - -/* 1280x720@50 Sync Polarity (GTF Mode) */ -#define M1280X720_R50_HSP NEGATIVE -#define M1280X720_R50_VSP POSITIVE - -/* 1280x720@60 Sync Polarity (CEA Mode) */ -#define M1280X720_CEA_R60_HSP POSITIVE -#define M1280X720_CEA_R60_VSP POSITIVE - -/* 1440x900@60 Sync Polarity (CVT Mode) */ -#define M1440X900_R60_HSP NEGATIVE -#define M1440X900_R60_VSP POSITIVE - -/* 1440x900@75 Sync Polarity (CVT Mode) */ -#define M1440X900_R75_HSP NEGATIVE -#define M1440X900_R75_VSP POSITIVE - -/* 1440x900@60 Sync Polarity (CVT Reduce Blanking Mode) */ -#define M1440X900_RB_R60_HSP POSITIVE -#define M1440X900_RB_R60_VSP NEGATIVE - -/* 1600x900@60 Sync Polarity (CVT Mode) */ -#define M1600X900_R60_HSP NEGATIVE -#define M1600X900_R60_VSP POSITIVE - -/* 1600x900@60 Sync Polarity (CVT Reduce Blanking Mode) */ -#define M1600X900_RB_R60_HSP POSITIVE -#define M1600X900_RB_R60_VSP NEGATIVE - -/* 1600x1024@60 Sync Polarity (GTF Mode) */ -#define M1600X1024_R60_HSP NEGATIVE -#define M1600X1024_R60_VSP POSITIVE - -/* 1792x1344@60 Sync Polarity (DMT Mode) */ -#define M1792x1344_R60_HSP NEGATIVE -#define M1792x1344_R60_VSP POSITIVE - -/* 1856x1392@60 Sync Polarity (DMT Mode) */ -#define M1856x1392_R60_HSP NEGATIVE -#define M1856x1392_R60_VSP POSITIVE - -/* 1920x1200@60 Sync Polarity (CVT Mode) */ -#define M1920X1200_R60_HSP NEGATIVE -#define M1920X1200_R60_VSP POSITIVE - -/* 1920x1200@60 Sync Polarity (CVT Reduce Blanking Mode) */ -#define M1920X1200_RB_R60_HSP POSITIVE -#define M1920X1200_RB_R60_VSP NEGATIVE - -/* 1920x1080@60 Sync Polarity (CEA Mode) */ -#define M1920X1080_CEA_R60_HSP POSITIVE -#define M1920X1080_CEA_R60_VSP POSITIVE - -/* 2048x1536@60 Sync Polarity (CVT Mode) */ -#define M2048x1536_R60_HSP NEGATIVE -#define M2048x1536_R60_VSP POSITIVE - -/* define PLL index: */ -#define CLK_25_175M 25175000 -#define CLK_26_880M 26880000 -#define CLK_29_581M 29581000 -#define CLK_31_500M 31500000 -#define CLK_31_728M 31728000 -#define CLK_32_668M 32688000 -#define CLK_36_000M 36000000 -#define CLK_40_000M 40000000 -#define CLK_41_291M 41291000 -#define CLK_43_163M 43163000 -#define CLK_45_250M 45250000 /* 45.46MHz */ -#define CLK_46_000M 46000000 -#define CLK_46_996M 46996000 -#define CLK_48_000M 48000000 -#define CLK_48_875M 48875000 -#define CLK_49_500M 49500000 -#define CLK_52_406M 52406000 -#define CLK_52_977M 52977000 -#define CLK_56_250M 56250000 -#define CLK_57_275M 57275000 -#define CLK_60_466M 60466000 -#define CLK_61_500M 61500000 -#define CLK_65_000M 65000000 -#define CLK_65_178M 65178000 -#define CLK_66_750M 66750000 /* 67.116MHz */ -#define CLK_68_179M 68179000 -#define CLK_69_924M 69924000 -#define CLK_70_159M 70159000 -#define CLK_72_000M 72000000 -#define CLK_74_270M 74270000 -#define CLK_78_750M 78750000 -#define CLK_80_136M 80136000 -#define CLK_83_375M 83375000 -#define CLK_83_950M 83950000 -#define CLK_84_750M 84750000 /* 84.537Mhz */ -#define CLK_85_860M 85860000 -#define CLK_88_750M 88750000 -#define CLK_94_500M 94500000 -#define CLK_97_750M 97750000 -#define CLK_101_000M 101000000 -#define CLK_106_500M 106500000 -#define CLK_108_000M 108000000 -#define CLK_113_309M 113309000 -#define CLK_118_840M 118840000 -#define CLK_119_000M 119000000 -#define CLK_121_750M 121750000 /* 121.704MHz */ -#define CLK_125_104M 125104000 -#define CLK_135_000M 135000000 -#define CLK_136_700M 136700000 -#define CLK_138_400M 138400000 -#define CLK_146_760M 146760000 -#define CLK_148_500M 148500000 - -#define CLK_153_920M 153920000 -#define CLK_156_000M 156000000 -#define CLK_157_500M 157500000 -#define CLK_162_000M 162000000 -#define CLK_187_000M 187000000 -#define CLK_193_295M 193295000 -#define CLK_202_500M 202500000 -#define CLK_204_000M 204000000 -#define CLK_218_500M 218500000 -#define CLK_234_000M 234000000 -#define CLK_267_250M 267250000 -#define CLK_297_500M 297500000 -#define CLK_74_481M 74481000 -#define CLK_172_798M 172798000 -#define CLK_122_614M 122614000 - - -/* Definition CRTC Timing Index */ -#define H_TOTAL_INDEX 0 -#define H_ADDR_INDEX 1 -#define H_BLANK_START_INDEX 2 -#define H_BLANK_END_INDEX 3 -#define H_SYNC_START_INDEX 4 -#define H_SYNC_END_INDEX 5 -#define V_TOTAL_INDEX 6 -#define V_ADDR_INDEX 7 -#define V_BLANK_START_INDEX 8 -#define V_BLANK_END_INDEX 9 -#define V_SYNC_START_INDEX 10 -#define V_SYNC_END_INDEX 11 -#define H_TOTAL_SHADOW_INDEX 12 -#define H_BLANK_END_SHADOW_INDEX 13 -#define V_TOTAL_SHADOW_INDEX 14 -#define V_ADDR_SHADOW_INDEX 15 -#define V_BLANK_SATRT_SHADOW_INDEX 16 -#define V_BLANK_END_SHADOW_INDEX 17 -#define V_SYNC_SATRT_SHADOW_INDEX 18 -#define V_SYNC_END_SHADOW_INDEX 19 - -/* Definition Video Mode Pixel Clock (picoseconds) -*/ -#define RES_480X640_60HZ_PIXCLOCK 39722 -#define RES_640X480_60HZ_PIXCLOCK 39722 -#define RES_640X480_75HZ_PIXCLOCK 31747 -#define RES_640X480_85HZ_PIXCLOCK 27777 -#define RES_640X480_100HZ_PIXCLOCK 23168 -#define RES_640X480_120HZ_PIXCLOCK 19081 -#define RES_720X480_60HZ_PIXCLOCK 37020 -#define RES_720X576_60HZ_PIXCLOCK 30611 -#define RES_800X600_60HZ_PIXCLOCK 25000 -#define RES_800X600_75HZ_PIXCLOCK 20203 -#define RES_800X600_85HZ_PIXCLOCK 17777 -#define RES_800X600_100HZ_PIXCLOCK 14667 -#define RES_800X600_120HZ_PIXCLOCK 11912 -#define RES_800X480_60HZ_PIXCLOCK 33805 -#define RES_848X480_60HZ_PIXCLOCK 31756 -#define RES_856X480_60HZ_PIXCLOCK 31518 -#define RES_1024X512_60HZ_PIXCLOCK 24218 -#define RES_1024X600_60HZ_PIXCLOCK 20460 -#define RES_1024X768_60HZ_PIXCLOCK 15385 -#define RES_1024X768_75HZ_PIXCLOCK 12699 -#define RES_1024X768_85HZ_PIXCLOCK 10582 -#define RES_1024X768_100HZ_PIXCLOCK 8825 -#define RES_1152X864_75HZ_PIXCLOCK 9259 -#define RES_1280X768_60HZ_PIXCLOCK 12480 -#define RES_1280X800_60HZ_PIXCLOCK 11994 -#define RES_1280X960_60HZ_PIXCLOCK 9259 -#define RES_1280X1024_60HZ_PIXCLOCK 9260 -#define RES_1280X1024_75HZ_PIXCLOCK 7408 -#define RES_1280X768_85HZ_PIXCLOCK 6349 -#define RES_1440X1050_60HZ_PIXCLOCK 7993 -#define RES_1600X1200_60HZ_PIXCLOCK 6172 -#define RES_1600X1200_75HZ_PIXCLOCK 4938 -#define RES_1280X720_60HZ_PIXCLOCK 13426 -#define RES_1200X900_60HZ_PIXCLOCK 17459 -#define RES_1920X1080_60HZ_PIXCLOCK 5787 -#define RES_1400X1050_60HZ_PIXCLOCK 8214 -#define RES_1400X1050_75HZ_PIXCLOCK 6410 -#define RES_1368X768_60HZ_PIXCLOCK 11647 -#define RES_960X600_60HZ_PIXCLOCK 22099 -#define RES_1000X600_60HZ_PIXCLOCK 20834 -#define RES_1024X576_60HZ_PIXCLOCK 21278 -#define RES_1088X612_60HZ_PIXCLOCK 18877 -#define RES_1152X720_60HZ_PIXCLOCK 14981 -#define RES_1200X720_60HZ_PIXCLOCK 14253 -#define RES_1280X600_60HZ_PIXCLOCK 16260 -#define RES_1280X720_50HZ_PIXCLOCK 16538 -#define RES_1280X768_50HZ_PIXCLOCK 15342 -#define RES_1366X768_50HZ_PIXCLOCK 14301 -#define RES_1366X768_60HZ_PIXCLOCK 11646 -#define RES_1360X768_60HZ_PIXCLOCK 11799 -#define RES_1440X900_60HZ_PIXCLOCK 9390 -#define RES_1440X900_75HZ_PIXCLOCK 7315 -#define RES_1600X900_60HZ_PIXCLOCK 8415 -#define RES_1600X1024_60HZ_PIXCLOCK 7315 -#define RES_1680X1050_60HZ_PIXCLOCK 6814 -#define RES_1680X1050_75HZ_PIXCLOCK 5348 -#define RES_1792X1344_60HZ_PIXCLOCK 4902 -#define RES_1856X1392_60HZ_PIXCLOCK 4577 -#define RES_1920X1200_60HZ_PIXCLOCK 5173 -#define RES_1920X1440_60HZ_PIXCLOCK 4274 -#define RES_1920X1440_75HZ_PIXCLOCK 3367 -#define RES_2048X1536_60HZ_PIXCLOCK 3742 - -#define RES_1360X768_RB_60HZ_PIXCLOCK 13889 -#define RES_1400X1050_RB_60HZ_PIXCLOCK 9901 -#define RES_1440X900_RB_60HZ_PIXCLOCK 11268 -#define RES_1600X900_RB_60HZ_PIXCLOCK 10230 -#define RES_1680X1050_RB_60HZ_PIXCLOCK 8403 -#define RES_1920X1080_RB_60HZ_PIXCLOCK 7225 -#define RES_1920X1200_RB_60HZ_PIXCLOCK 6497 - -/* LCD display method -*/ -#define LCD_EXPANDSION 0x00 -#define LCD_CENTERING 0x01 - -/* LCD mode -*/ -#define LCD_OPENLDI 0x00 -#define LCD_SPWG 0x01 - -/* Define display timing -*/ -struct display_timing { - u16 hor_total; - u16 hor_addr; - u16 hor_blank_start; - u16 hor_blank_end; - u16 hor_sync_start; - u16 hor_sync_end; - u16 ver_total; - u16 ver_addr; - u16 ver_blank_start; - u16 ver_blank_end; - u16 ver_sync_start; - u16 ver_sync_end; -}; - -struct crt_mode_table { - int refresh_rate; - unsigned long clk; - int h_sync_polarity; - int v_sync_polarity; - struct display_timing crtc; -}; - -struct io_reg { - int port; - u8 index; - u8 mask; - u8 value; -}; - -#endif /* __SHARE_H__ */ diff --git a/drivers/video/via/tblDPASetting.c b/drivers/video/via/tblDPASetting.c deleted file mode 100644 index 0c4c8cc712f..00000000000 --- a/drivers/video/via/tblDPASetting.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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" -/* For VT3324: */ -struct VT1636_DPA_SETTING VT1636_DPA_SETTING_TBL_VT3324[] = { - /* Panel ID, CLK_SEL_ST1[09], CLK_SEL_ST2[08] */ - {LCD_PANEL_ID0_640X480, 0x00, 0x00}, /* For 640x480 */ - {LCD_PANEL_ID1_800X600, 0x00, 0x00}, /* For 800x600 */ - {LCD_PANEL_ID2_1024X768, 0x00, 0x00}, /* For 1024x768 */ - {LCD_PANEL_ID3_1280X768, 0x00, 0x00}, /* For 1280x768 */ - {LCD_PANEL_ID4_1280X1024, 0x00, 0x00}, /* For 1280x1024 */ - {LCD_PANEL_ID5_1400X1050, 0x00, 0x00}, /* For 1400x1050 */ - {LCD_PANEL_ID6_1600X1200, 0x0B, 0x03} /* For 1600x1200 */ -}; - -struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3324[] = { -/* ClkRange, DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1, - DVP1Driving, DFPHigh, DFPLow */ -/* CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], CR9B, - SR65, CR97, CR99 */ - /* LCK/VCK < 30000000 will use this value */ - {DPA_CLK_RANGE_30M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x00}, - /* 30000000 < LCK/VCK < 50000000 will use this value */ - {DPA_CLK_RANGE_30_50M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x00}, - /* 50000000 < LCK/VCK < 70000000 will use this value */ - {DPA_CLK_RANGE_50_70M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00}, - /* 70000000 < LCK/VCK < 100000000 will use this value */ - {DPA_CLK_RANGE_70_100M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00}, - /* 100000000 < LCK/VCK < 15000000 will use this value */ - {DPA_CLK_RANGE_100_150M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00}, - /* 15000000 < LCK/VCK will use this value */ - {DPA_CLK_RANGE_150M, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0E, 0x00, - 0x00}, -}; - -/* For VT3327: */ -struct VT1636_DPA_SETTING VT1636_DPA_SETTING_TBL_VT3327[] = { - /* Panel ID, CLK_SEL_ST1[09], CLK_SEL_ST2[08] */ - {LCD_PANEL_ID0_640X480, 0x00, 0x00}, /* For 640x480 */ - {LCD_PANEL_ID1_800X600, 0x00, 0x00}, /* For 800x600 */ - {LCD_PANEL_ID2_1024X768, 0x00, 0x00}, /* For 1024x768 */ - {LCD_PANEL_ID3_1280X768, 0x00, 0x00}, /* For 1280x768 */ - {LCD_PANEL_ID4_1280X1024, 0x00, 0x00}, /* For 1280x1024 */ - {LCD_PANEL_ID5_1400X1050, 0x00, 0x00}, /* For 1400x1050 */ - {LCD_PANEL_ID6_1600X1200, 0x00, 0x00} /* For 1600x1200 */ -}; - -struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3327[] = { -/* ClkRange,DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1, - DVP1Driving, DFPHigh, DFPLow */ -/* CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], CR9B, - SR65, CR97, CR99 */ -/* LCK/VCK < 30000000 will use this value */ -{DPA_CLK_RANGE_30M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x01}, -/* 30000000 < LCK/VCK < 50000000 will use this value */ -{DPA_CLK_RANGE_30_50M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x01}, -/* 50000000 < LCK/VCK < 70000000 will use this value */ -{DPA_CLK_RANGE_50_70M, 0x06, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x01}, -/* 70000000 < LCK/VCK < 100000000 will use this value */ -{DPA_CLK_RANGE_70_100M, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x03}, -/* 100000000 < LCK/VCK < 15000000 will use this value */ -{DPA_CLK_RANGE_100_150M, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x02}, -/* 15000000 < LCK/VCK will use this value */ -{DPA_CLK_RANGE_150M, 0x00, 0x20, 0x00, 0x10, 0x00, 0x03, 0x00, 0x0D, 0x03}, -}; - -/* For VT3364: */ -struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3364[] = { -/* ClkRange,DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1, - DVP1Driving, DFPHigh, DFPLow */ -/* CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], CR9B, - SR65, CR97, CR99 */ -/* LCK/VCK < 30000000 will use this value */ -{DPA_CLK_RANGE_30M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08}, -/* 30000000 < LCK/VCK < 50000000 will use this value */ -{DPA_CLK_RANGE_30_50M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08}, -/* 50000000 < LCK/VCK < 70000000 will use this value */ -{DPA_CLK_RANGE_50_70M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08}, -/* 70000000 < LCK/VCK < 100000000 will use this value */ -{DPA_CLK_RANGE_70_100M, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08}, -/* 100000000 < LCK/VCK < 15000000 will use this value */ -{DPA_CLK_RANGE_100_150M, 0x03, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08}, -/* 15000000 < LCK/VCK will use this value */ -{DPA_CLK_RANGE_150M, 0x01, 0x00, 0x02, 0x10, 0x00, 0x03, 0x00, 0x00, 0x08}, -}; diff --git a/drivers/video/via/tblDPASetting.h b/drivers/video/via/tblDPASetting.h deleted file mode 100644 index b065a83481d..00000000000 --- a/drivers/video/via/tblDPASetting.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 _TBLDPASETTING_H_ -#define _TBLDPASETTING_H_ -#include "global.h" - -#define DPA_CLK_30M 30000000 -#define DPA_CLK_50M 50000000 -#define DPA_CLK_70M 70000000 -#define DPA_CLK_100M 100000000 -#define DPA_CLK_150M 150000000 - -enum DPA_RANGE { - DPA_CLK_RANGE_30M, - DPA_CLK_RANGE_30_50M, - DPA_CLK_RANGE_50_70M, - DPA_CLK_RANGE_70_100M, - DPA_CLK_RANGE_100_150M, - DPA_CLK_RANGE_150M -}; - -extern struct VT1636_DPA_SETTING VT1636_DPA_SETTING_TBL_VT3324[7]; -extern struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3324[6]; -extern struct VT1636_DPA_SETTING VT1636_DPA_SETTING_TBL_VT3327[7]; -extern struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3327[]; -extern struct GFX_DPA_SETTING GFX_DPA_SETTING_TBL_VT3364[6]; - -#endif diff --git a/drivers/video/via/via-core.c b/drivers/video/via/via-core.c deleted file mode 100644 index 6723d6910cd..00000000000 --- a/drivers/video/via/via-core.c +++ /dev/null @@ -1,784 +0,0 @@ -/* - * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. - * Copyright 2009 Jonathan Corbet <corbet@lwn.net> - */ - -/* - * Core code for the Via multifunction framebuffer device. - */ -#include <linux/via-core.h> -#include <linux/via_i2c.h> -#include <linux/via-gpio.h> -#include "global.h" - -#include <linux/module.h> -#include <linux/interrupt.h> -#include <linux/platform_device.h> -#include <linux/list.h> -#include <linux/pm.h> -#include <asm/olpc.h> - -/* - * The default port config. - */ -static struct via_port_cfg adap_configs[] = { - [VIA_PORT_26] = { VIA_PORT_I2C, VIA_MODE_I2C, VIASR, 0x26 }, - [VIA_PORT_31] = { VIA_PORT_I2C, VIA_MODE_I2C, VIASR, 0x31 }, - [VIA_PORT_25] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x25 }, - [VIA_PORT_2C] = { VIA_PORT_GPIO, VIA_MODE_I2C, VIASR, 0x2c }, - [VIA_PORT_3D] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x3d }, - { 0, 0, 0, 0 } -}; - -/* - * The OLPC XO-1.5 puts the camera power and reset lines onto - * GPIO 2C. - */ -static const struct via_port_cfg olpc_adap_configs[] = { - [VIA_PORT_26] = { VIA_PORT_I2C, VIA_MODE_I2C, VIASR, 0x26 }, - [VIA_PORT_31] = { VIA_PORT_I2C, VIA_MODE_I2C, VIASR, 0x31 }, - [VIA_PORT_25] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x25 }, - [VIA_PORT_2C] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x2c }, - [VIA_PORT_3D] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x3d }, - { 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; - - -/* - * Basic register access; spinlock required. - */ -static inline void viafb_mmio_write(int reg, u32 v) -{ - iowrite32(v, global_dev.engine_mmio + reg); -} - -static inline int viafb_mmio_read(int reg) -{ - return ioread32(global_dev.engine_mmio + reg); -} - -/* ---------------------------------------------------------------------- */ -/* - * Interrupt management. We have a single IRQ line for a lot of - * different functions, so we need to share it. The design here - * is that we don't want to reimplement the shared IRQ code here; - * we also want to avoid having contention for a single handler thread. - * So each subdev driver which needs interrupts just requests - * them directly from the kernel. We just have what's needed for - * overall access to the interrupt control register. - */ - -/* - * Which interrupts are enabled now? - */ -static u32 viafb_enabled_ints; - -static void __devinit viafb_int_init(void) -{ - viafb_enabled_ints = 0; - - viafb_mmio_write(VDE_INTERRUPT, 0); -} - -/* - * Allow subdevs to ask for specific interrupts to be enabled. These - * functions must be called with reg_lock held - */ -void viafb_irq_enable(u32 mask) -{ - viafb_enabled_ints |= mask; - viafb_mmio_write(VDE_INTERRUPT, viafb_enabled_ints | VDE_I_ENABLE); -} -EXPORT_SYMBOL_GPL(viafb_irq_enable); - -void viafb_irq_disable(u32 mask) -{ - viafb_enabled_ints &= ~mask; - if (viafb_enabled_ints == 0) - viafb_mmio_write(VDE_INTERRUPT, 0); /* Disable entirely */ - else - viafb_mmio_write(VDE_INTERRUPT, - viafb_enabled_ints | VDE_I_ENABLE); -} -EXPORT_SYMBOL_GPL(viafb_irq_disable); - -/* ---------------------------------------------------------------------- */ -/* - * Currently, the camera driver is the only user of the DMA code, so we - * only compile it in if the camera driver is being built. Chances are, - * most viafb systems will not need to have this extra code for a while. - * As soon as another user comes long, the ifdef can be removed. - */ -#if defined(CONFIG_VIDEO_VIA_CAMERA) || defined(CONFIG_VIDEO_VIA_CAMERA_MODULE) -/* - * Access to the DMA engine. This currently provides what the camera - * driver needs (i.e. outgoing only) but is easily expandable if need - * be. - */ - -/* - * There are four DMA channels in the vx855. For now, we only - * use one of them, though. Most of the time, the DMA channel - * will be idle, so we keep the IRQ handler unregistered except - * when some subsystem has indicated an interest. - */ -static int viafb_dma_users; -static DECLARE_COMPLETION(viafb_dma_completion); -/* - * This mutex protects viafb_dma_users and our global interrupt - * registration state; it also serializes access to the DMA - * engine. - */ -static DEFINE_MUTEX(viafb_dma_lock); - -/* - * The VX855 DMA descriptor (used for s/g transfers) looks - * like this. - */ -struct viafb_vx855_dma_descr { - u32 addr_low; /* Low part of phys addr */ - u32 addr_high; /* High 12 bits of addr */ - u32 fb_offset; /* Offset into FB memory */ - u32 seg_size; /* Size, 16-byte units */ - u32 tile_mode; /* "tile mode" setting */ - u32 next_desc_low; /* Next descriptor addr */ - u32 next_desc_high; - u32 pad; /* Fill out to 64 bytes */ -}; - -/* - * Flags added to the "next descriptor low" pointers - */ -#define VIAFB_DMA_MAGIC 0x01 /* ??? Just has to be there */ -#define VIAFB_DMA_FINAL_SEGMENT 0x02 /* Final segment */ - -/* - * The completion IRQ handler. - */ -static irqreturn_t viafb_dma_irq(int irq, void *data) -{ - int csr; - irqreturn_t ret = IRQ_NONE; - - spin_lock(&global_dev.reg_lock); - csr = viafb_mmio_read(VDMA_CSR0); - if (csr & VDMA_C_DONE) { - viafb_mmio_write(VDMA_CSR0, VDMA_C_DONE); - complete(&viafb_dma_completion); - ret = IRQ_HANDLED; - } - spin_unlock(&global_dev.reg_lock); - return ret; -} - -/* - * Indicate a need for DMA functionality. - */ -int viafb_request_dma(void) -{ - int ret = 0; - - /* - * Only VX855 is supported currently. - */ - if (global_dev.chip_type != UNICHROME_VX855) - return -ENODEV; - /* - * Note the new user and set up our interrupt handler - * if need be. - */ - mutex_lock(&viafb_dma_lock); - viafb_dma_users++; - if (viafb_dma_users == 1) { - ret = request_irq(global_dev.pdev->irq, viafb_dma_irq, - IRQF_SHARED, "via-dma", &viafb_dma_users); - if (ret) - viafb_dma_users--; - else - viafb_irq_enable(VDE_I_DMA0TDEN); - } - mutex_unlock(&viafb_dma_lock); - return ret; -} -EXPORT_SYMBOL_GPL(viafb_request_dma); - -void viafb_release_dma(void) -{ - mutex_lock(&viafb_dma_lock); - viafb_dma_users--; - if (viafb_dma_users == 0) { - viafb_irq_disable(VDE_I_DMA0TDEN); - free_irq(global_dev.pdev->irq, &viafb_dma_users); - } - mutex_unlock(&viafb_dma_lock); -} -EXPORT_SYMBOL_GPL(viafb_release_dma); - - -#if 0 -/* - * Copy a single buffer from FB memory, synchronously. This code works - * but is not currently used. - */ -void viafb_dma_copy_out(unsigned int offset, dma_addr_t paddr, int len) -{ - unsigned long flags; - int csr; - - mutex_lock(&viafb_dma_lock); - init_completion(&viafb_dma_completion); - /* - * Program the controller. - */ - spin_lock_irqsave(&global_dev.reg_lock, flags); - viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_DONE); - /* Enable ints; must happen after CSR0 write! */ - viafb_mmio_write(VDMA_MR0, VDMA_MR_TDIE); - viafb_mmio_write(VDMA_MARL0, (int) (paddr & 0xfffffff0)); - viafb_mmio_write(VDMA_MARH0, (int) ((paddr >> 28) & 0xfff)); - /* Data sheet suggests DAR0 should be <<4, but it lies */ - viafb_mmio_write(VDMA_DAR0, offset); - viafb_mmio_write(VDMA_DQWCR0, len >> 4); - viafb_mmio_write(VDMA_TMR0, 0); - viafb_mmio_write(VDMA_DPRL0, 0); - viafb_mmio_write(VDMA_DPRH0, 0); - viafb_mmio_write(VDMA_PMR0, 0); - csr = viafb_mmio_read(VDMA_CSR0); - viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_START); - spin_unlock_irqrestore(&global_dev.reg_lock, flags); - /* - * Now we just wait until the interrupt handler says - * we're done. - */ - wait_for_completion_interruptible(&viafb_dma_completion); - viafb_mmio_write(VDMA_MR0, 0); /* Reset int enable */ - mutex_unlock(&viafb_dma_lock); -} -EXPORT_SYMBOL_GPL(viafb_dma_copy_out); -#endif - -/* - * Do a scatter/gather DMA copy from FB memory. You must have done - * a successful call to viafb_request_dma() first. - */ -int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg) -{ - struct viafb_vx855_dma_descr *descr; - void *descrpages; - dma_addr_t descr_handle; - unsigned long flags; - int i; - struct scatterlist *sgentry; - dma_addr_t nextdesc; - - /* - * Get a place to put the descriptors. - */ - descrpages = dma_alloc_coherent(&global_dev.pdev->dev, - nsg*sizeof(struct viafb_vx855_dma_descr), - &descr_handle, GFP_KERNEL); - if (descrpages == NULL) { - dev_err(&global_dev.pdev->dev, "Unable to get descr page.\n"); - return -ENOMEM; - } - mutex_lock(&viafb_dma_lock); - /* - * Fill them in. - */ - descr = descrpages; - nextdesc = descr_handle + sizeof(struct viafb_vx855_dma_descr); - for_each_sg(sg, sgentry, nsg, i) { - dma_addr_t paddr = sg_dma_address(sgentry); - descr->addr_low = paddr & 0xfffffff0; - descr->addr_high = ((u64) paddr >> 32) & 0x0fff; - descr->fb_offset = offset; - descr->seg_size = sg_dma_len(sgentry) >> 4; - descr->tile_mode = 0; - descr->next_desc_low = (nextdesc&0xfffffff0) | VIAFB_DMA_MAGIC; - descr->next_desc_high = ((u64) nextdesc >> 32) & 0x0fff; - descr->pad = 0xffffffff; /* VIA driver does this */ - offset += sg_dma_len(sgentry); - nextdesc += sizeof(struct viafb_vx855_dma_descr); - descr++; - } - descr[-1].next_desc_low = VIAFB_DMA_FINAL_SEGMENT|VIAFB_DMA_MAGIC; - /* - * Program the engine. - */ - spin_lock_irqsave(&global_dev.reg_lock, flags); - init_completion(&viafb_dma_completion); - viafb_mmio_write(VDMA_DQWCR0, 0); - viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_DONE); - viafb_mmio_write(VDMA_MR0, VDMA_MR_TDIE | VDMA_MR_CHAIN); - viafb_mmio_write(VDMA_DPRL0, descr_handle | VIAFB_DMA_MAGIC); - viafb_mmio_write(VDMA_DPRH0, - (((u64)descr_handle >> 32) & 0x0fff) | 0xf0000); - (void) viafb_mmio_read(VDMA_CSR0); - viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_START); - spin_unlock_irqrestore(&global_dev.reg_lock, flags); - /* - * Now we just wait until the interrupt handler says - * we're done. Except that, actually, we need to wait a little - * longer: the interrupts seem to jump the gun a little and we - * get corrupted frames sometimes. - */ - wait_for_completion_timeout(&viafb_dma_completion, 1); - msleep(1); - if ((viafb_mmio_read(VDMA_CSR0)&VDMA_C_DONE) == 0) - printk(KERN_ERR "VIA DMA timeout!\n"); - /* - * Clean up and we're done. - */ - viafb_mmio_write(VDMA_CSR0, VDMA_C_DONE); - viafb_mmio_write(VDMA_MR0, 0); /* Reset int enable */ - mutex_unlock(&viafb_dma_lock); - dma_free_coherent(&global_dev.pdev->dev, - nsg*sizeof(struct viafb_vx855_dma_descr), descrpages, - descr_handle); - return 0; -} -EXPORT_SYMBOL_GPL(viafb_dma_copy_out_sg); -#endif /* CONFIG_VIDEO_VIA_CAMERA */ - -/* ---------------------------------------------------------------------- */ -/* - * 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, VX900_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 VX900_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) -{ - int ret; - /* - * Hook up to the device registers. Note that we soldier - * on if it fails; the framebuffer can operate (without - * acceleration) without this region. - */ - vdev->engine_start = pci_resource_start(vdev->pdev, 1); - vdev->engine_len = pci_resource_len(vdev->pdev, 1); - vdev->engine_mmio = ioremap_nocache(vdev->engine_start, - vdev->engine_len); - if (vdev->engine_mmio == NULL) - dev_err(&vdev->pdev->dev, - "Unable to map engine MMIO; operation will be " - "slow and crippled.\n"); - /* - * Map in framebuffer memory. For now, failure here is - * fatal. Unfortunately, in the absence of significant - * vmalloc space, failure here is also entirely plausible. - * Eventually we want to move away from mapping this - * entire region. - */ - if (vdev->chip_type == UNICHROME_VX900) - vdev->fbmem_start = pci_resource_start(vdev->pdev, 2); - else - vdev->fbmem_start = pci_resource_start(vdev->pdev, 0); - ret = vdev->fbmem_len = viafb_get_fb_size_from_pci(vdev->chip_type); - if (ret < 0) - goto out_unmap; - vdev->fbmem = ioremap_nocache(vdev->fbmem_start, vdev->fbmem_len); - if (vdev->fbmem == NULL) { - ret = -ENOMEM; - goto out_unmap; - } - return 0; -out_unmap: - iounmap(vdev->engine_mmio); - return ret; -} - -static void via_pci_teardown_mmio(struct viafb_dev *vdev) -{ - iounmap(vdev->fbmem); - iounmap(vdev->engine_mmio); -} - -/* - * Create our subsidiary devices. - */ -static struct viafb_subdev_info { - char *name; - struct platform_device *platdev; -} viafb_subdevs[] = { - { - .name = "viafb-gpio", - }, - { - .name = "viafb-i2c", - }, -#if defined(CONFIG_VIDEO_VIA_CAMERA) || defined(CONFIG_VIDEO_VIA_CAMERA_MODULE) - { - .name = "viafb-camera", - }, -#endif -}; -#define N_SUBDEVS ARRAY_SIZE(viafb_subdevs) - -static int __devinit via_create_subdev(struct viafb_dev *vdev, - struct viafb_subdev_info *info) -{ - int ret; - - info->platdev = platform_device_alloc(info->name, -1); - if (!info->platdev) { - dev_err(&vdev->pdev->dev, "Unable to allocate pdev %s\n", - info->name); - return -ENOMEM; - } - info->platdev->dev.parent = &vdev->pdev->dev; - info->platdev->dev.platform_data = vdev; - ret = platform_device_add(info->platdev); - if (ret) { - dev_err(&vdev->pdev->dev, "Unable to add pdev %s\n", - info->name); - platform_device_put(info->platdev); - info->platdev = NULL; - } - return ret; -} - -static int __devinit via_setup_subdevs(struct viafb_dev *vdev) -{ - int i; - - /* - * Ignore return values. Even if some of the devices - * fail to be created, we'll still be able to use some - * of the rest. - */ - for (i = 0; i < N_SUBDEVS; i++) - via_create_subdev(vdev, viafb_subdevs + i); - return 0; -} - -static void via_teardown_subdevs(void) -{ - int i; - - for (i = 0; i < N_SUBDEVS; i++) - if (viafb_subdevs[i].platdev) { - viafb_subdevs[i].platdev->dev.platform_data = NULL; - platform_device_unregister(viafb_subdevs[i].platdev); - } -} - -/* - * Power management functions - */ -#ifdef CONFIG_PM -static LIST_HEAD(viafb_pm_hooks); -static DEFINE_MUTEX(viafb_pm_hooks_lock); - -void viafb_pm_register(struct viafb_pm_hooks *hooks) -{ - INIT_LIST_HEAD(&hooks->list); - - mutex_lock(&viafb_pm_hooks_lock); - list_add_tail(&hooks->list, &viafb_pm_hooks); - mutex_unlock(&viafb_pm_hooks_lock); -} -EXPORT_SYMBOL_GPL(viafb_pm_register); - -void viafb_pm_unregister(struct viafb_pm_hooks *hooks) -{ - mutex_lock(&viafb_pm_hooks_lock); - list_del(&hooks->list); - mutex_unlock(&viafb_pm_hooks_lock); -} -EXPORT_SYMBOL_GPL(viafb_pm_unregister); - -static int via_suspend(struct pci_dev *pdev, pm_message_t state) -{ - struct viafb_pm_hooks *hooks; - - if (state.event != PM_EVENT_SUSPEND) - return 0; - /* - * "I've occasionally hit a few drivers that caused suspend - * failures, and each and every time it was a driver bug, and - * the right thing to do was to just ignore the error and suspend - * anyway - returning an error code and trying to undo the suspend - * is not what anybody ever really wants, even if our model - *_allows_ for it." - * -- Linus Torvalds, Dec. 7, 2009 - */ - mutex_lock(&viafb_pm_hooks_lock); - list_for_each_entry_reverse(hooks, &viafb_pm_hooks, list) - hooks->suspend(hooks->private); - mutex_unlock(&viafb_pm_hooks_lock); - - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - return 0; -} - -static int via_resume(struct pci_dev *pdev) -{ - struct viafb_pm_hooks *hooks; - - /* Get the bus side powered up */ - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - if (pci_enable_device(pdev)) - return 0; - - pci_set_master(pdev); - - /* Now bring back any subdevs */ - mutex_lock(&viafb_pm_hooks_lock); - list_for_each_entry(hooks, &viafb_pm_hooks, list) - hooks->resume(hooks->private); - mutex_unlock(&viafb_pm_hooks_lock); - - return 0; -} -#endif /* CONFIG_PM */ - -static int __devinit via_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *ent) -{ - int ret; - - ret = pci_enable_device(pdev); - if (ret) - return ret; - - /* - * Global device initialization. - */ - memset(&global_dev, 0, sizeof(global_dev)); - global_dev.pdev = pdev; - global_dev.chip_type = ent->driver_data; - global_dev.port_cfg = adap_configs; - if (machine_is_olpc()) - global_dev.port_cfg = olpc_adap_configs; - - spin_lock_init(&global_dev.reg_lock); - ret = via_pci_setup_mmio(&global_dev); - if (ret) - goto out_disable; - /* - * Set up interrupts and create our subdevices. Continue even if - * some things fail. - */ - viafb_int_init(); - via_setup_subdevs(&global_dev); - /* - * Set up the framebuffer device - */ - ret = via_fb_pci_probe(&global_dev); - if (ret) - goto out_subdevs; - return 0; - -out_subdevs: - via_teardown_subdevs(); - via_pci_teardown_mmio(&global_dev); -out_disable: - pci_disable_device(pdev); - return ret; -} - -static void __devexit via_pci_remove(struct pci_dev *pdev) -{ - via_teardown_subdevs(); - via_fb_pci_remove(pdev); - via_pci_teardown_mmio(&global_dev); - pci_disable_device(pdev); -} - - -static struct pci_device_id via_pci_table[] __devinitdata = { - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CLE266_DID), - .driver_data = UNICHROME_CLE266 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K400_DID), - .driver_data = UNICHROME_K400 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K800_DID), - .driver_data = UNICHROME_K800 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_PM800_DID), - .driver_data = UNICHROME_PM800 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CN700_DID), - .driver_data = UNICHROME_CN700 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CX700_DID), - .driver_data = UNICHROME_CX700 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CN750_DID), - .driver_data = UNICHROME_CN750 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K8M890_DID), - .driver_data = UNICHROME_K8M890 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M890_DID), - .driver_data = UNICHROME_P4M890 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M900_DID), - .driver_data = UNICHROME_P4M900 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX800_DID), - .driver_data = UNICHROME_VX800 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX855_DID), - .driver_data = UNICHROME_VX855 }, - { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX900_DID), - .driver_data = UNICHROME_VX900 }, - { } -}; -MODULE_DEVICE_TABLE(pci, via_pci_table); - -static struct pci_driver via_driver = { - .name = "viafb", - .id_table = via_pci_table, - .probe = via_pci_probe, - .remove = __devexit_p(via_pci_remove), -#ifdef CONFIG_PM - .suspend = via_suspend, - .resume = via_resume, -#endif -}; - -static int __init via_core_init(void) -{ - int ret; - - ret = viafb_init(); - if (ret) - return ret; - viafb_i2c_init(); - viafb_gpio_init(); - return pci_register_driver(&via_driver); -} - -static void __exit via_core_exit(void) -{ - pci_unregister_driver(&via_driver); - viafb_gpio_exit(); - viafb_i2c_exit(); - viafb_exit(); -} - -module_init(via_core_init); -module_exit(via_core_exit); diff --git a/drivers/video/via/via-gpio.c b/drivers/video/via/via-gpio.c deleted file mode 100644 index c2a0a1cfd3b..00000000000 --- a/drivers/video/via/via-gpio.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Support for viafb GPIO ports. - * - * Copyright 2009 Jonathan Corbet <corbet@lwn.net> - * Distributable under version 2 of the GNU General Public License. - */ - -#include <linux/spinlock.h> -#include <linux/gpio.h> -#include <linux/platform_device.h> -#include <linux/via-core.h> -#include <linux/via-gpio.h> - -/* - * The ports we know about. Note that the port-25 gpios are not - * mentioned in the datasheet. - */ - -struct viafb_gpio { - char *vg_name; /* Data sheet name */ - u16 vg_io_port; - u8 vg_port_index; - int vg_mask_shift; -}; - -static struct viafb_gpio viafb_all_gpios[] = { - { - .vg_name = "VGPIO0", /* Guess - not in datasheet */ - .vg_io_port = VIASR, - .vg_port_index = 0x25, - .vg_mask_shift = 1 - }, - { - .vg_name = "VGPIO1", - .vg_io_port = VIASR, - .vg_port_index = 0x25, - .vg_mask_shift = 0 - }, - { - .vg_name = "VGPIO2", /* aka DISPCLKI0 */ - .vg_io_port = VIASR, - .vg_port_index = 0x2c, - .vg_mask_shift = 1 - }, - { - .vg_name = "VGPIO3", /* aka DISPCLKO0 */ - .vg_io_port = VIASR, - .vg_port_index = 0x2c, - .vg_mask_shift = 0 - }, - { - .vg_name = "VGPIO4", /* DISPCLKI1 */ - .vg_io_port = VIASR, - .vg_port_index = 0x3d, - .vg_mask_shift = 1 - }, - { - .vg_name = "VGPIO5", /* DISPCLKO1 */ - .vg_io_port = VIASR, - .vg_port_index = 0x3d, - .vg_mask_shift = 0 - }, -}; - -#define VIAFB_NUM_GPIOS ARRAY_SIZE(viafb_all_gpios) - -/* - * This structure controls the active GPIOs, which may be a subset - * of those which are known. - */ - -struct viafb_gpio_cfg { - struct gpio_chip gpio_chip; - struct viafb_dev *vdev; - struct viafb_gpio *active_gpios[VIAFB_NUM_GPIOS]; - const char *gpio_names[VIAFB_NUM_GPIOS]; -}; - -/* - * GPIO access functions - */ -static void via_gpio_set(struct gpio_chip *chip, unsigned int nr, - int value) -{ - struct viafb_gpio_cfg *cfg = container_of(chip, - struct viafb_gpio_cfg, - gpio_chip); - u8 reg; - struct viafb_gpio *gpio; - unsigned long flags; - - spin_lock_irqsave(&cfg->vdev->reg_lock, flags); - gpio = cfg->active_gpios[nr]; - reg = via_read_reg(VIASR, gpio->vg_port_index); - reg |= 0x40 << gpio->vg_mask_shift; /* output enable */ - if (value) - reg |= 0x10 << gpio->vg_mask_shift; - else - reg &= ~(0x10 << gpio->vg_mask_shift); - via_write_reg(VIASR, gpio->vg_port_index, reg); - spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); -} - -static int via_gpio_dir_out(struct gpio_chip *chip, unsigned int nr, - int value) -{ - via_gpio_set(chip, nr, value); - return 0; -} - -/* - * Set the input direction. I'm not sure this is right; we should - * be able to do input without disabling output. - */ -static int via_gpio_dir_input(struct gpio_chip *chip, unsigned int nr) -{ - struct viafb_gpio_cfg *cfg = container_of(chip, - struct viafb_gpio_cfg, - gpio_chip); - struct viafb_gpio *gpio; - unsigned long flags; - - spin_lock_irqsave(&cfg->vdev->reg_lock, flags); - gpio = cfg->active_gpios[nr]; - via_write_reg_mask(VIASR, gpio->vg_port_index, 0, - 0x40 << gpio->vg_mask_shift); - spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); - return 0; -} - -static int via_gpio_get(struct gpio_chip *chip, unsigned int nr) -{ - struct viafb_gpio_cfg *cfg = container_of(chip, - struct viafb_gpio_cfg, - gpio_chip); - u8 reg; - struct viafb_gpio *gpio; - unsigned long flags; - - spin_lock_irqsave(&cfg->vdev->reg_lock, flags); - gpio = cfg->active_gpios[nr]; - reg = via_read_reg(VIASR, gpio->vg_port_index); - spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); - return reg & (0x04 << gpio->vg_mask_shift); -} - - -static struct viafb_gpio_cfg gpio_config = { - .gpio_chip = { - .label = "VIAFB onboard GPIO", - .owner = THIS_MODULE, - .direction_output = via_gpio_dir_out, - .set = via_gpio_set, - .direction_input = via_gpio_dir_input, - .get = via_gpio_get, - .base = -1, - .ngpio = 0, - .can_sleep = 0 - } -}; - -/* - * Manage the software enable bit. - */ -static void viafb_gpio_enable(struct viafb_gpio *gpio) -{ - via_write_reg_mask(VIASR, gpio->vg_port_index, 0x02, 0x02); -} - -static void viafb_gpio_disable(struct viafb_gpio *gpio) -{ - via_write_reg_mask(VIASR, gpio->vg_port_index, 0, 0x02); -} - -#ifdef CONFIG_PM - -static int viafb_gpio_suspend(void *private) -{ - return 0; -} - -static int viafb_gpio_resume(void *private) -{ - int i; - - for (i = 0; i < gpio_config.gpio_chip.ngpio; i += 2) - viafb_gpio_enable(gpio_config.active_gpios[i]); - return 0; -} - -static struct viafb_pm_hooks viafb_gpio_pm_hooks = { - .suspend = viafb_gpio_suspend, - .resume = viafb_gpio_resume -}; -#endif /* CONFIG_PM */ - -/* - * Look up a specific gpio and return the number it was assigned. - */ -int viafb_gpio_lookup(const char *name) -{ - int i; - - for (i = 0; i < gpio_config.gpio_chip.ngpio; i++) - if (!strcmp(name, gpio_config.active_gpios[i]->vg_name)) - return gpio_config.gpio_chip.base + i; - return -1; -} -EXPORT_SYMBOL_GPL(viafb_gpio_lookup); - -/* - * Platform device stuff. - */ -static __devinit int viafb_gpio_probe(struct platform_device *platdev) -{ - struct viafb_dev *vdev = platdev->dev.platform_data; - struct via_port_cfg *port_cfg = vdev->port_cfg; - int i, ngpio = 0, ret; - struct viafb_gpio *gpio; - unsigned long flags; - - /* - * Set up entries for all GPIOs which have been configured to - * operate as such (as opposed to as i2c ports). - */ - for (i = 0; i < VIAFB_NUM_PORTS; i++) { - if (port_cfg[i].mode != VIA_MODE_GPIO) - continue; - for (gpio = viafb_all_gpios; - gpio < viafb_all_gpios + VIAFB_NUM_GPIOS; gpio++) - if (gpio->vg_port_index == port_cfg[i].ioport_index) { - gpio_config.active_gpios[ngpio] = gpio; - gpio_config.gpio_names[ngpio] = gpio->vg_name; - ngpio++; - } - } - gpio_config.gpio_chip.ngpio = ngpio; - gpio_config.gpio_chip.names = gpio_config.gpio_names; - gpio_config.vdev = vdev; - if (ngpio == 0) { - printk(KERN_INFO "viafb: no GPIOs configured\n"); - return 0; - } - /* - * Enable the ports. They come in pairs, with a single - * enable bit for both. - */ - spin_lock_irqsave(&gpio_config.vdev->reg_lock, flags); - for (i = 0; i < ngpio; i += 2) - viafb_gpio_enable(gpio_config.active_gpios[i]); - spin_unlock_irqrestore(&gpio_config.vdev->reg_lock, flags); - /* - * Get registered. - */ - gpio_config.gpio_chip.base = -1; /* Dynamic */ - ret = gpiochip_add(&gpio_config.gpio_chip); - if (ret) { - printk(KERN_ERR "viafb: failed to add gpios (%d)\n", ret); - gpio_config.gpio_chip.ngpio = 0; - } -#ifdef CONFIG_PM - viafb_pm_register(&viafb_gpio_pm_hooks); -#endif - return ret; -} - - -static int viafb_gpio_remove(struct platform_device *platdev) -{ - unsigned long flags; - int ret = 0, i; - -#ifdef CONFIG_PM - viafb_pm_unregister(&viafb_gpio_pm_hooks); -#endif - - /* - * Get unregistered. - */ - if (gpio_config.gpio_chip.ngpio > 0) { - ret = gpiochip_remove(&gpio_config.gpio_chip); - if (ret) { /* Somebody still using it? */ - printk(KERN_ERR "Viafb: GPIO remove failed\n"); - return ret; - } - } - /* - * Disable the ports. - */ - spin_lock_irqsave(&gpio_config.vdev->reg_lock, flags); - for (i = 0; i < gpio_config.gpio_chip.ngpio; i += 2) - viafb_gpio_disable(gpio_config.active_gpios[i]); - gpio_config.gpio_chip.ngpio = 0; - spin_unlock_irqrestore(&gpio_config.vdev->reg_lock, flags); - return ret; -} - -static struct platform_driver via_gpio_driver = { - .driver = { - .name = "viafb-gpio", - }, - .probe = viafb_gpio_probe, - .remove = viafb_gpio_remove, -}; - -int viafb_gpio_init(void) -{ - return platform_driver_register(&via_gpio_driver); -} - -void viafb_gpio_exit(void) -{ - platform_driver_unregister(&via_gpio_driver); -} diff --git a/drivers/video/via/via_i2c.c b/drivers/video/via/via_i2c.c deleted file mode 100644 index 3844b558b7b..00000000000 --- a/drivers/video/via/via_i2c.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright 1998-2009 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 <linux/platform_device.h> -#include <linux/delay.h> -#include <linux/spinlock.h> -#include <linux/module.h> -#include <linux/via-core.h> -#include <linux/via_i2c.h> - -/* - * There can only be one set of these, so there's no point in having - * them be dynamically allocated... - */ -#define VIAFB_NUM_I2C 5 -static struct via_i2c_stuff via_i2c_par[VIAFB_NUM_I2C]; -struct viafb_dev *i2c_vdev; /* Passed in from core */ - -static void via_i2c_setscl(void *data, int state) -{ - u8 val; - struct via_port_cfg *adap_data = data; - unsigned long flags; - - spin_lock_irqsave(&i2c_vdev->reg_lock, flags); - val = via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0xF0; - if (state) - val |= 0x20; - else - val &= ~0x20; - switch (adap_data->type) { - case VIA_PORT_I2C: - val |= 0x01; - break; - case VIA_PORT_GPIO: - val |= 0x80; - break; - default: - printk(KERN_ERR "viafb_i2c: specify wrong i2c type.\n"); - } - via_write_reg(adap_data->io_port, adap_data->ioport_index, val); - spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags); -} - -static int via_i2c_getscl(void *data) -{ - struct via_port_cfg *adap_data = data; - unsigned long flags; - int ret = 0; - - spin_lock_irqsave(&i2c_vdev->reg_lock, flags); - if (via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0x08) - ret = 1; - spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags); - return ret; -} - -static int via_i2c_getsda(void *data) -{ - struct via_port_cfg *adap_data = data; - unsigned long flags; - int ret = 0; - - spin_lock_irqsave(&i2c_vdev->reg_lock, flags); - if (via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0x04) - ret = 1; - spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags); - return ret; -} - -static void via_i2c_setsda(void *data, int state) -{ - u8 val; - struct via_port_cfg *adap_data = data; - unsigned long flags; - - spin_lock_irqsave(&i2c_vdev->reg_lock, flags); - val = via_read_reg(adap_data->io_port, adap_data->ioport_index) & 0xF0; - if (state) - val |= 0x10; - else - val &= ~0x10; - switch (adap_data->type) { - case VIA_PORT_I2C: - val |= 0x01; - break; - case VIA_PORT_GPIO: - val |= 0x40; - break; - default: - printk(KERN_ERR "viafb_i2c: specify wrong i2c type.\n"); - } - via_write_reg(adap_data->io_port, adap_data->ioport_index, val); - spin_unlock_irqrestore(&i2c_vdev->reg_lock, flags); -} - -int viafb_i2c_readbyte(u8 adap, u8 slave_addr, u8 index, u8 *pdata) -{ - int ret; - u8 mm1[] = {0x00}; - struct i2c_msg msgs[2]; - - if (!via_i2c_par[adap].is_active) - return -ENODEV; - *pdata = 0; - msgs[0].flags = 0; - msgs[1].flags = I2C_M_RD; - msgs[0].addr = msgs[1].addr = slave_addr / 2; - mm1[0] = index; - msgs[0].len = 1; msgs[1].len = 1; - msgs[0].buf = mm1; msgs[1].buf = pdata; - ret = i2c_transfer(&via_i2c_par[adap].adapter, msgs, 2); - if (ret == 2) - ret = 0; - else if (ret >= 0) - ret = -EIO; - - return ret; -} - -int viafb_i2c_writebyte(u8 adap, u8 slave_addr, u8 index, u8 data) -{ - int ret; - u8 msg[2] = { index, data }; - struct i2c_msg msgs; - - if (!via_i2c_par[adap].is_active) - return -ENODEV; - msgs.flags = 0; - msgs.addr = slave_addr / 2; - msgs.len = 2; - msgs.buf = msg; - ret = i2c_transfer(&via_i2c_par[adap].adapter, &msgs, 1); - if (ret == 1) - ret = 0; - else if (ret >= 0) - ret = -EIO; - - return ret; -} - -int viafb_i2c_readbytes(u8 adap, u8 slave_addr, u8 index, u8 *buff, int buff_len) -{ - int ret; - u8 mm1[] = {0x00}; - struct i2c_msg msgs[2]; - - if (!via_i2c_par[adap].is_active) - return -ENODEV; - msgs[0].flags = 0; - msgs[1].flags = I2C_M_RD; - msgs[0].addr = msgs[1].addr = slave_addr / 2; - mm1[0] = index; - msgs[0].len = 1; msgs[1].len = buff_len; - msgs[0].buf = mm1; msgs[1].buf = buff; - ret = i2c_transfer(&via_i2c_par[adap].adapter, msgs, 2); - if (ret == 2) - ret = 0; - else if (ret >= 0) - ret = -EIO; - - return ret; -} - -/* - * Allow other viafb subdevices to look up a specific adapter - * by port name. - */ -struct i2c_adapter *viafb_find_i2c_adapter(enum viafb_i2c_adap which) -{ - struct via_i2c_stuff *stuff = &via_i2c_par[which]; - - return &stuff->adapter; -} -EXPORT_SYMBOL_GPL(viafb_find_i2c_adapter); - - -static int create_i2c_bus(struct i2c_adapter *adapter, - struct i2c_algo_bit_data *algo, - struct via_port_cfg *adap_cfg, - struct pci_dev *pdev) -{ - algo->setsda = via_i2c_setsda; - algo->setscl = via_i2c_setscl; - algo->getsda = via_i2c_getsda; - algo->getscl = via_i2c_getscl; - algo->udelay = 10; - algo->timeout = 2; - algo->data = adap_cfg; - - sprintf(adapter->name, "viafb i2c io_port idx 0x%02x", - adap_cfg->ioport_index); - adapter->owner = THIS_MODULE; - adapter->id = 0x01FFFF; - adapter->class = I2C_CLASS_DDC; - adapter->algo_data = algo; - if (pdev) - adapter->dev.parent = &pdev->dev; - else - adapter->dev.parent = NULL; - /* i2c_set_adapdata(adapter, adap_cfg); */ - - /* Raise SCL and SDA */ - via_i2c_setsda(adap_cfg, 1); - via_i2c_setscl(adap_cfg, 1); - udelay(20); - - return i2c_bit_add_bus(adapter); -} - -static int viafb_i2c_probe(struct platform_device *platdev) -{ - int i, ret; - struct via_port_cfg *configs; - - i2c_vdev = platdev->dev.platform_data; - configs = i2c_vdev->port_cfg; - - for (i = 0; i < VIAFB_NUM_PORTS; i++) { - struct via_port_cfg *adap_cfg = configs++; - struct via_i2c_stuff *i2c_stuff = &via_i2c_par[i]; - - i2c_stuff->is_active = 0; - if (adap_cfg->type == 0 || adap_cfg->mode != VIA_MODE_I2C) - continue; - ret = create_i2c_bus(&i2c_stuff->adapter, - &i2c_stuff->algo, adap_cfg, - NULL); /* FIXME: PCIDEV */ - if (ret < 0) { - printk(KERN_ERR "viafb: cannot create i2c bus %u:%d\n", - i, ret); - continue; /* Still try to make the rest */ - } - i2c_stuff->is_active = 1; - } - - return 0; -} - -static int viafb_i2c_remove(struct platform_device *platdev) -{ - int i; - - for (i = 0; i < VIAFB_NUM_PORTS; i++) { - struct via_i2c_stuff *i2c_stuff = &via_i2c_par[i]; - /* - * Only remove those entries in the array that we've - * actually used (and thus initialized algo_data) - */ - if (i2c_stuff->is_active) - i2c_del_adapter(&i2c_stuff->adapter); - } - return 0; -} - -static struct platform_driver via_i2c_driver = { - .driver = { - .name = "viafb-i2c", - }, - .probe = viafb_i2c_probe, - .remove = viafb_i2c_remove, -}; - -int viafb_i2c_init(void) -{ - return platform_driver_register(&via_i2c_driver); -} - -void viafb_i2c_exit(void) -{ - platform_driver_unregister(&via_i2c_driver); -} diff --git a/drivers/video/via/via_modesetting.c b/drivers/video/via/via_modesetting.c deleted file mode 100644 index 3cddcff88ab..00000000000 --- a/drivers/video/via/via_modesetting.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. - * Copyright 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> - * - * 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. - */ -/* - * basic modesetting functions - */ - -#include <linux/kernel.h> -#include <linux/via-core.h> -#include "via_modesetting.h" -#include "share.h" -#include "debug.h" - -void via_set_primary_address(u32 addr) -{ - DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr); - via_write_reg(VIACR, 0x0D, addr & 0xFF); - via_write_reg(VIACR, 0x0C, (addr >> 8) & 0xFF); - via_write_reg(VIACR, 0x34, (addr >> 16) & 0xFF); - via_write_reg_mask(VIACR, 0x48, (addr >> 24) & 0x1F, 0x1F); -} - -void via_set_secondary_address(u32 addr) -{ - DEBUG_MSG(KERN_DEBUG "via_set_secondary_address(0x%08X)\n", addr); - /* secondary display supports only quadword aligned memory */ - via_write_reg_mask(VIACR, 0x62, (addr >> 2) & 0xFE, 0xFE); - via_write_reg(VIACR, 0x63, (addr >> 10) & 0xFF); - via_write_reg(VIACR, 0x64, (addr >> 18) & 0xFF); - via_write_reg_mask(VIACR, 0xA3, (addr >> 26) & 0x07, 0x07); -} - -void via_set_primary_pitch(u32 pitch) -{ - DEBUG_MSG(KERN_DEBUG "via_set_primary_pitch(0x%08X)\n", pitch); - /* spec does not say that first adapter skips 3 bits but old - * code did it and seems to be reasonable in analogy to 2nd adapter - */ - pitch = pitch >> 3; - via_write_reg(VIACR, 0x13, pitch & 0xFF); - via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0); -} - -void via_set_secondary_pitch(u32 pitch) -{ - DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch); - pitch = pitch >> 3; - via_write_reg(VIACR, 0x66, pitch & 0xFF); - via_write_reg_mask(VIACR, 0x67, (pitch >> 8) & 0x03, 0x03); - via_write_reg_mask(VIACR, 0x71, (pitch >> (10 - 7)) & 0x80, 0x80); -} - -void via_set_primary_color_depth(u8 depth) -{ - u8 value; - - DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth); - switch (depth) { - case 8: - value = 0x00; - break; - case 15: - value = 0x04; - break; - case 16: - value = 0x14; - break; - case 24: - value = 0x0C; - break; - case 30: - value = 0x08; - break; - default: - printk(KERN_WARNING "via_set_primary_color_depth: " - "Unsupported depth: %d\n", depth); - return; - } - - via_write_reg_mask(VIASR, 0x15, value, 0x1C); -} - -void via_set_secondary_color_depth(u8 depth) -{ - u8 value; - - DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth); - switch (depth) { - case 8: - value = 0x00; - break; - case 16: - value = 0x40; - break; - case 24: - value = 0xC0; - break; - case 30: - value = 0x80; - break; - default: - printk(KERN_WARNING "via_set_secondary_color_depth: " - "Unsupported depth: %d\n", depth); - return; - } - - via_write_reg_mask(VIACR, 0x67, value, 0xC0); -} diff --git a/drivers/video/via/via_modesetting.h b/drivers/video/via/via_modesetting.h deleted file mode 100644 index ae35cfdeb37..00000000000 --- a/drivers/video/via/via_modesetting.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. - * Copyright 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> - * - * 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. - */ -/* - * basic modesetting functions - */ - -#ifndef __VIA_MODESETTING_H__ -#define __VIA_MODESETTING_H__ - -#include <linux/types.h> - -void via_set_primary_address(u32 addr); -void via_set_secondary_address(u32 addr); -void via_set_primary_pitch(u32 pitch); -void via_set_secondary_pitch(u32 pitch); -void via_set_primary_color_depth(u8 depth); -void via_set_secondary_color_depth(u8 depth); - -#endif /* __VIA_MODESETTING_H__ */ diff --git a/drivers/video/via/via_utility.c b/drivers/video/via/via_utility.c deleted file mode 100644 index d05ccb62b55..00000000000 --- a/drivers/video/via/via_utility.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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 <linux/via-core.h> -#include "global.h" - -void viafb_get_device_support_state(u32 *support_state) -{ - *support_state = CRT_Device; - - if (viaparinfo->chip_info->tmds_chip_info.tmds_chip_name == VT1632_TMDS) - *support_state |= DVI_Device; - - if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name == VT1631_LVDS) - *support_state |= LCD_Device; -} - -void viafb_get_device_connect_state(u32 *connect_state) -{ - bool mobile = false; - - *connect_state = CRT_Device; - - if (viafb_dvi_sense()) - *connect_state |= DVI_Device; - - viafb_lcd_get_mobile_state(&mobile); - if (mobile) - *connect_state |= LCD_Device; -} - -bool viafb_lcd_get_support_expand_state(u32 xres, u32 yres) -{ - unsigned int support_state = 0; - - switch (viafb_lcd_panel_id) { - case LCD_PANEL_ID0_640X480: - if ((xres < 640) && (yres < 480)) - support_state = true; - break; - - case LCD_PANEL_ID1_800X600: - if ((xres < 800) && (yres < 600)) - support_state = true; - break; - - case LCD_PANEL_ID2_1024X768: - if ((xres < 1024) && (yres < 768)) - support_state = true; - break; - - case LCD_PANEL_ID3_1280X768: - if ((xres < 1280) && (yres < 768)) - support_state = true; - break; - - case LCD_PANEL_ID4_1280X1024: - if ((xres < 1280) && (yres < 1024)) - support_state = true; - break; - - case LCD_PANEL_ID5_1400X1050: - if ((xres < 1400) && (yres < 1050)) - support_state = true; - break; - - case LCD_PANEL_ID6_1600X1200: - if ((xres < 1600) && (yres < 1200)) - support_state = true; - break; - - case LCD_PANEL_ID7_1366X768: - if ((xres < 1366) && (yres < 768)) - support_state = true; - break; - - case LCD_PANEL_ID8_1024X600: - if ((xres < 1024) && (yres < 600)) - support_state = true; - break; - - case LCD_PANEL_ID9_1280X800: - if ((xres < 1280) && (yres < 800)) - support_state = true; - break; - - case LCD_PANEL_IDA_800X480: - if ((xres < 800) && (yres < 480)) - support_state = true; - break; - - case LCD_PANEL_IDB_1360X768: - if ((xres < 1360) && (yres < 768)) - support_state = true; - break; - - case LCD_PANEL_IDC_480X640: - if ((xres < 480) && (yres < 640)) - support_state = true; - break; - - default: - support_state = false; - break; - } - - return support_state; -} - -/*====================================================================*/ -/* Gamma Function Implementation*/ -/*====================================================================*/ - -void viafb_set_gamma_table(int bpp, unsigned int *gamma_table) -{ - int i, sr1a; - int active_device_amount = 0; - int device_status = viafb_DeviceStatus; - - for (i = 0; i < sizeof(viafb_DeviceStatus) * 8; i++) { - if (device_status & 1) - active_device_amount++; - device_status >>= 1; - } - - /* 8 bpp mode can't adjust gamma */ - if (bpp == 8) - return ; - - /* Enable Gamma */ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CLE266: - case UNICHROME_K400: - viafb_write_reg_mask(SR16, VIASR, 0x80, BIT7); - break; - - case UNICHROME_K800: - case UNICHROME_PM800: - case UNICHROME_CN700: - case UNICHROME_CX700: - case UNICHROME_K8M890: - case UNICHROME_P4M890: - case UNICHROME_P4M900: - viafb_write_reg_mask(CR33, VIACR, 0x80, BIT7); - break; - } - sr1a = (unsigned int)viafb_read_reg(VIASR, SR1A); - viafb_write_reg_mask(SR1A, VIASR, 0x0, BIT0); - - /* Fill IGA1 Gamma Table */ - outb(0, LUT_INDEX_WRITE); - for (i = 0; i < 256; i++) { - outb(gamma_table[i] >> 16, LUT_DATA); - outb(gamma_table[i] >> 8 & 0xFF, LUT_DATA); - outb(gamma_table[i] & 0xFF, LUT_DATA); - } - - /* If adjust Gamma value in SAMM, fill IGA1, - IGA2 Gamma table simultanous. */ - /* Switch to IGA2 Gamma Table */ - if ((active_device_amount > 1) && - !((viaparinfo->chip_info->gfx_chip_name == - UNICHROME_CLE266) && - (viaparinfo->chip_info->gfx_chip_revision < 15))) { - viafb_write_reg_mask(SR1A, VIASR, 0x01, BIT0); - viafb_write_reg_mask(CR6A, VIACR, 0x02, BIT1); - - /* Fill IGA2 Gamma Table */ - outb(0, LUT_INDEX_WRITE); - for (i = 0; i < 256; i++) { - outb(gamma_table[i] >> 16, LUT_DATA); - outb(gamma_table[i] >> 8 & 0xFF, LUT_DATA); - outb(gamma_table[i] & 0xFF, LUT_DATA); - } - } - viafb_write_reg(SR1A, VIASR, sr1a); -} - -void viafb_get_gamma_table(unsigned int *gamma_table) -{ - unsigned char color_r, color_g, color_b; - unsigned char sr1a = 0; - int i; - - /* Enable Gamma */ - switch (viaparinfo->chip_info->gfx_chip_name) { - case UNICHROME_CLE266: - case UNICHROME_K400: - viafb_write_reg_mask(SR16, VIASR, 0x80, BIT7); - break; - - case UNICHROME_K800: - case UNICHROME_PM800: - case UNICHROME_CN700: - case UNICHROME_CX700: - case UNICHROME_K8M890: - case UNICHROME_P4M890: - case UNICHROME_P4M900: - viafb_write_reg_mask(CR33, VIACR, 0x80, BIT7); - break; - } - sr1a = viafb_read_reg(VIASR, SR1A); - viafb_write_reg_mask(SR1A, VIASR, 0x0, BIT0); - - /* Reading gamma table to get color value */ - outb(0, LUT_INDEX_READ); - for (i = 0; i < 256; i++) { - color_r = inb(LUT_DATA); - color_g = inb(LUT_DATA); - color_b = inb(LUT_DATA); - gamma_table[i] = - ((((u32) color_r) << 16) | - (((u16) color_g) << 8)) | color_b; - } - viafb_write_reg(SR1A, VIASR, sr1a); -} - -void viafb_get_gamma_support_state(int bpp, unsigned int *support_state) -{ - if (bpp == 8) - *support_state = None_Device; - else - *support_state = CRT_Device | DVI_Device | LCD_Device; -} diff --git a/drivers/video/via/via_utility.h b/drivers/video/via/via_utility.h deleted file mode 100644 index 1670ba82143..00000000000 --- a/drivers/video/via/via_utility.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 __VIAUTILITY_H__ -#define __VIAUTILITY_H__ - -/* These functions are used to get infomation about device's state */ -void viafb_get_device_support_state(u32 *support_state); -void viafb_get_device_connect_state(u32 *connect_state); -bool viafb_lcd_get_support_expand_state(u32 xres, u32 yres); - -/* These function are used to access gamma table */ -void viafb_set_gamma_table(int bpp, unsigned int *gamma_table); -void viafb_get_gamma_table(unsigned int *gamma_table); -void viafb_get_gamma_support_state(int bpp, unsigned int *support_state); - -#endif /* __VIAUTILITY_H__ */ diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c deleted file mode 100644 index 289edd51952..00000000000 --- a/drivers/video/via/viafbdev.c +++ /dev/null @@ -1,2125 +0,0 @@ -/* - * Copyright 1998-2009 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 <linux/module.h> -#include <linux/seq_file.h> -#include <linux/slab.h> -#include <linux/stat.h> -#include <linux/via-core.h> - -#define _MASTER_FILE -#include "global.h" - -static char *viafb_name = "Via"; -static u32 pseudo_pal[17]; - -/* video mode */ -static char *viafb_mode; -static char *viafb_mode1; -static int viafb_bpp = 32; -static int viafb_bpp1 = 32; - -static unsigned int viafb_second_offset; -static int viafb_second_size; - -static int viafb_accel = 1; - -/* Added for specifying active devices.*/ -char *viafb_active_dev; - -/*Added for specify lcd output port*/ -char *viafb_lcd_port = ""; -char *viafb_dvi_port = ""; - -static void retrieve_device_setting(struct viafb_ioctl_setting - *setting_info); -static int viafb_pan_display(struct fb_var_screeninfo *var, - struct fb_info *info); - -static struct fb_ops viafb_ops; - -/* supported output devices on each IGP - * only CX700, VX800, VX855, VX900 were documented - * VIA_CRT should be everywhere - * VIA_6C can be onle pre-CX700 (probably only on CLE266) as 6C is used for PLL - * source selection on CX700 and later - * K400 seems to support VIA_96, VIA_DVP1, VIA_LVDS{1,2} as in viamode.c - */ -static const u32 supported_odev_map[] = { - [UNICHROME_CLE266] = VIA_CRT | VIA_LDVP0 | VIA_LDVP1, - [UNICHROME_K400] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 - | VIA_LVDS2, - [UNICHROME_K800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 - | VIA_LVDS2, - [UNICHROME_PM800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 - | VIA_LVDS2, - [UNICHROME_CN700] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 - | VIA_LVDS2, - [UNICHROME_CX700] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, - [UNICHROME_CN750] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, - [UNICHROME_K8M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, - [UNICHROME_P4M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, - [UNICHROME_P4M900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, - [UNICHROME_VX800] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, - [UNICHROME_VX855] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, - [UNICHROME_VX900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, -}; - -static void viafb_fill_var_color_info(struct fb_var_screeninfo *var, u8 depth) -{ - var->grayscale = 0; - var->red.msb_right = 0; - var->green.msb_right = 0; - var->blue.msb_right = 0; - var->transp.offset = 0; - var->transp.length = 0; - var->transp.msb_right = 0; - var->nonstd = 0; - switch (depth) { - case 8: - var->bits_per_pixel = 8; - var->red.offset = 0; - var->green.offset = 0; - var->blue.offset = 0; - var->red.length = 8; - var->green.length = 8; - var->blue.length = 8; - break; - case 15: - var->bits_per_pixel = 16; - var->red.offset = 10; - var->green.offset = 5; - var->blue.offset = 0; - var->red.length = 5; - var->green.length = 5; - var->blue.length = 5; - break; - case 16: - var->bits_per_pixel = 16; - var->red.offset = 11; - var->green.offset = 5; - var->blue.offset = 0; - var->red.length = 5; - var->green.length = 6; - var->blue.length = 5; - break; - case 24: - var->bits_per_pixel = 32; - var->red.offset = 16; - var->green.offset = 8; - var->blue.offset = 0; - var->red.length = 8; - var->green.length = 8; - var->blue.length = 8; - break; - case 30: - var->bits_per_pixel = 32; - var->red.offset = 20; - var->green.offset = 10; - var->blue.offset = 0; - var->red.length = 10; - var->green.length = 10; - var->blue.length = 10; - break; - } -} - -static void viafb_update_fix(struct fb_info *info) -{ - u32 bpp = info->var.bits_per_pixel; - - info->fix.visual = - bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; - info->fix.line_length = (info->var.xres_virtual * bpp / 8 + 7) & ~7; -} - -static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix, - struct viafb_par *viaparinfo) -{ - memset(fix, 0, sizeof(struct fb_fix_screeninfo)); - strcpy(fix->id, viafb_name); - - fix->smem_start = viaparinfo->fbmem; - fix->smem_len = viaparinfo->fbmem_free; - - fix->type = FB_TYPE_PACKED_PIXELS; - fix->type_aux = 0; - fix->visual = FB_VISUAL_TRUECOLOR; - - fix->xpanstep = fix->ywrapstep = 0; - fix->ypanstep = 1; - - /* Just tell the accel name */ - viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME; -} -static int viafb_open(struct fb_info *info, int user) -{ - DEBUG_MSG(KERN_INFO "viafb_open!\n"); - return 0; -} - -static int viafb_release(struct fb_info *info, int user) -{ - DEBUG_MSG(KERN_INFO "viafb_release!\n"); - return 0; -} - -static int viafb_check_var(struct fb_var_screeninfo *var, - struct fb_info *info) -{ - int htotal, vtotal, depth; - struct VideoModeTable *vmode_entry; - struct viafb_par *ppar = info->par; - u32 long_refresh, line; - - DEBUG_MSG(KERN_INFO "viafb_check_var!\n"); - /* Sanity check */ - /* HW neither support interlacte nor double-scaned mode */ - if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE) - return -EINVAL; - - vmode_entry = viafb_get_mode(var->xres, var->yres); - if (!vmode_entry) { - DEBUG_MSG(KERN_INFO - "viafb: Mode %dx%dx%d not supported!!\n", - var->xres, var->yres, var->bits_per_pixel); - return -EINVAL; - } - - depth = fb_get_color_depth(var, &info->fix); - if (!depth) - depth = var->bits_per_pixel; - - if (depth < 0 || depth > 32) - return -EINVAL; - else if (!depth) - depth = 24; - else if (depth == 15 && viafb_dual_fb && ppar->iga_path == IGA1) - depth = 15; - else if (depth == 30) - depth = 30; - else if (depth <= 8) - depth = 8; - else if (depth <= 16) - depth = 16; - else - depth = 24; - - viafb_fill_var_color_info(var, depth); - line = (var->xres_virtual * var->bits_per_pixel / 8 + 7) & ~7; - if (line * var->yres_virtual > ppar->memsize) - return -EINVAL; - - /* Based on var passed in to calculate the refresh, - * because our driver use some modes special. - */ - htotal = var->xres + var->left_margin + - var->right_margin + var->hsync_len; - vtotal = var->yres + var->upper_margin + - var->lower_margin + var->vsync_len; - long_refresh = 1000000000UL / var->pixclock * 1000; - long_refresh /= (htotal * vtotal); - - viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh); - - /* Adjust var according to our driver's own table */ - viafb_fill_var_timing_info(var, viafb_refresh, vmode_entry); - if (var->accel_flags & FB_ACCELF_TEXT && - !ppar->shared->vdev->engine_mmio) - var->accel_flags = 0; - - return 0; -} - -static int viafb_set_par(struct fb_info *info) -{ - struct viafb_par *viapar = info->par; - struct VideoModeTable *vmode_entry, *vmode_entry1 = NULL; - DEBUG_MSG(KERN_INFO "viafb_set_par!\n"); - - viafb_update_fix(info); - viapar->depth = fb_get_color_depth(&info->var, &info->fix); - viafb_update_device_setting(viafbinfo->var.xres, viafbinfo->var.yres, - viafbinfo->var.bits_per_pixel, viafb_refresh, 0); - - vmode_entry = viafb_get_mode(viafbinfo->var.xres, viafbinfo->var.yres); - if (viafb_dual_fb) { - vmode_entry1 = viafb_get_mode(viafbinfo1->var.xres, - viafbinfo1->var.yres); - viafb_update_device_setting(viafbinfo1->var.xres, - viafbinfo1->var.yres, viafbinfo1->var.bits_per_pixel, - viafb_refresh1, 1); - } else if (viafb_SAMM_ON == 1) { - DEBUG_MSG(KERN_INFO - "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n", - viafb_second_xres, viafb_second_yres, viafb_bpp1); - vmode_entry1 = viafb_get_mode(viafb_second_xres, - viafb_second_yres); - - viafb_update_device_setting(viafb_second_xres, - viafb_second_yres, viafb_bpp1, viafb_refresh1, 1); - } - - if (vmode_entry) { - if (viafb_dual_fb && viapar->iga_path == IGA2) - viafb_bpp1 = info->var.bits_per_pixel; - else - viafb_bpp = info->var.bits_per_pixel; - - if (info->var.accel_flags & FB_ACCELF_TEXT) - info->flags &= ~FBINFO_HWACCEL_DISABLED; - else - info->flags |= FBINFO_HWACCEL_DISABLED; - viafb_setmode(vmode_entry, info->var.bits_per_pixel, - vmode_entry1, viafb_bpp1); - viafb_pan_display(&info->var, info); - } - - return 0; -} - -/* Set one color register */ -static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green, -unsigned blue, unsigned transp, struct fb_info *info) -{ - struct viafb_par *viapar = info->par; - u32 r, g, b; - - if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) { - if (regno > 255) - return -EINVAL; - - if (!viafb_dual_fb || viapar->iga_path == IGA1) - viafb_set_primary_color_register(regno, red >> 8, - green >> 8, blue >> 8); - - if (!viafb_dual_fb || viapar->iga_path == IGA2) - viafb_set_secondary_color_register(regno, red >> 8, - green >> 8, blue >> 8); - } else { - if (regno > 15) - return -EINVAL; - - r = (red >> (16 - info->var.red.length)) - << info->var.red.offset; - b = (blue >> (16 - info->var.blue.length)) - << info->var.blue.offset; - g = (green >> (16 - info->var.green.length)) - << info->var.green.offset; - ((u32 *) info->pseudo_palette)[regno] = r | g | b; - } - - return 0; -} - -static int viafb_pan_display(struct fb_var_screeninfo *var, - struct fb_info *info) -{ - struct viafb_par *viapar = info->par; - u32 vram_addr = (var->yoffset * var->xres_virtual + var->xoffset) - * (var->bits_per_pixel / 8) + viapar->vram_addr; - - DEBUG_MSG(KERN_DEBUG "viafb_pan_display, address = %d\n", vram_addr); - if (!viafb_dual_fb) { - via_set_primary_address(vram_addr); - via_set_secondary_address(vram_addr); - } else if (viapar->iga_path == IGA1) - via_set_primary_address(vram_addr); - else - via_set_secondary_address(vram_addr); - - return 0; -} - -static int viafb_blank(int blank_mode, struct fb_info *info) -{ - DEBUG_MSG(KERN_INFO "viafb_blank!\n"); - /* clear DPMS setting */ - - switch (blank_mode) { - case FB_BLANK_UNBLANK: - /* Screen: On, HSync: On, VSync: On */ - /* control CRT monitor power management */ - via_set_state(VIA_CRT, VIA_STATE_ON); - break; - case FB_BLANK_HSYNC_SUSPEND: - /* Screen: Off, HSync: Off, VSync: On */ - /* control CRT monitor power management */ - via_set_state(VIA_CRT, VIA_STATE_STANDBY); - break; - case FB_BLANK_VSYNC_SUSPEND: - /* Screen: Off, HSync: On, VSync: Off */ - /* control CRT monitor power management */ - via_set_state(VIA_CRT, VIA_STATE_SUSPEND); - break; - case FB_BLANK_POWERDOWN: - /* Screen: Off, HSync: Off, VSync: Off */ - /* control CRT monitor power management */ - via_set_state(VIA_CRT, VIA_STATE_OFF); - break; - } - - return 0; -} - -static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) -{ - union { - struct viafb_ioctl_mode viamode; - struct viafb_ioctl_samm viasamm; - struct viafb_driver_version driver_version; - struct fb_var_screeninfo sec_var; - struct _panel_size_pos_info panel_pos_size_para; - struct viafb_ioctl_setting viafb_setting; - struct device_t active_dev; - } u; - u32 state_info = 0; - u32 *viafb_gamma_table; - char driver_name[] = "viafb"; - - u32 __user *argp = (u32 __user *) arg; - u32 gpu32; - - DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd); - printk(KERN_WARNING "viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n"); - memset(&u, 0, sizeof(u)); - - switch (cmd) { - case VIAFB_GET_CHIP_INFO: - if (copy_to_user(argp, viaparinfo->chip_info, - sizeof(struct chip_information))) - return -EFAULT; - break; - case VIAFB_GET_INFO_SIZE: - return put_user((u32)sizeof(struct viafb_ioctl_info), argp); - case VIAFB_GET_INFO: - return viafb_ioctl_get_viafb_info(arg); - case VIAFB_HOTPLUG: - return put_user(viafb_ioctl_hotplug(info->var.xres, - info->var.yres, - info->var.bits_per_pixel), argp); - case VIAFB_SET_HOTPLUG_FLAG: - if (copy_from_user(&gpu32, argp, sizeof(gpu32))) - return -EFAULT; - viafb_hotplug = (gpu32) ? 1 : 0; - break; - case VIAFB_GET_RESOLUTION: - u.viamode.xres = (u32) viafb_hotplug_Xres; - u.viamode.yres = (u32) viafb_hotplug_Yres; - u.viamode.refresh = (u32) viafb_hotplug_refresh; - u.viamode.bpp = (u32) viafb_hotplug_bpp; - if (viafb_SAMM_ON == 1) { - u.viamode.xres_sec = viafb_second_xres; - u.viamode.yres_sec = viafb_second_yres; - u.viamode.virtual_xres_sec = viafb_second_virtual_xres; - u.viamode.virtual_yres_sec = viafb_second_virtual_yres; - u.viamode.refresh_sec = viafb_refresh1; - u.viamode.bpp_sec = viafb_bpp1; - } else { - u.viamode.xres_sec = 0; - u.viamode.yres_sec = 0; - u.viamode.virtual_xres_sec = 0; - u.viamode.virtual_yres_sec = 0; - u.viamode.refresh_sec = 0; - u.viamode.bpp_sec = 0; - } - if (copy_to_user(argp, &u.viamode, sizeof(u.viamode))) - return -EFAULT; - break; - case VIAFB_GET_SAMM_INFO: - u.viasamm.samm_status = viafb_SAMM_ON; - - if (viafb_SAMM_ON == 1) { - if (viafb_dual_fb) { - u.viasamm.size_prim = viaparinfo->fbmem_free; - u.viasamm.size_sec = viaparinfo1->fbmem_free; - } else { - if (viafb_second_size) { - u.viasamm.size_prim = - viaparinfo->fbmem_free - - viafb_second_size * 1024 * 1024; - u.viasamm.size_sec = - viafb_second_size * 1024 * 1024; - } else { - u.viasamm.size_prim = - viaparinfo->fbmem_free >> 1; - u.viasamm.size_sec = - (viaparinfo->fbmem_free >> 1); - } - } - u.viasamm.mem_base = viaparinfo->fbmem; - u.viasamm.offset_sec = viafb_second_offset; - } else { - u.viasamm.size_prim = - viaparinfo->memsize - viaparinfo->fbmem_used; - u.viasamm.size_sec = 0; - u.viasamm.mem_base = viaparinfo->fbmem; - u.viasamm.offset_sec = 0; - } - - if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm))) - return -EFAULT; - - break; - case VIAFB_TURN_ON_OUTPUT_DEVICE: - if (copy_from_user(&gpu32, argp, sizeof(gpu32))) - return -EFAULT; - if (gpu32 & CRT_Device) - via_set_state(VIA_CRT, VIA_STATE_ON); - if (gpu32 & DVI_Device) - viafb_dvi_enable(); - if (gpu32 & LCD_Device) - viafb_lcd_enable(); - break; - case VIAFB_TURN_OFF_OUTPUT_DEVICE: - if (copy_from_user(&gpu32, argp, sizeof(gpu32))) - return -EFAULT; - if (gpu32 & CRT_Device) - via_set_state(VIA_CRT, VIA_STATE_OFF); - if (gpu32 & DVI_Device) - viafb_dvi_disable(); - if (gpu32 & LCD_Device) - viafb_lcd_disable(); - break; - case VIAFB_GET_DEVICE: - u.active_dev.crt = viafb_CRT_ON; - u.active_dev.dvi = viafb_DVI_ON; - u.active_dev.lcd = viafb_LCD_ON; - u.active_dev.samm = viafb_SAMM_ON; - u.active_dev.primary_dev = viafb_primary_dev; - - u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method; - u.active_dev.lcd_panel_id = viafb_lcd_panel_id; - u.active_dev.lcd_mode = viafb_lcd_mode; - - u.active_dev.xres = viafb_hotplug_Xres; - u.active_dev.yres = viafb_hotplug_Yres; - - u.active_dev.xres1 = viafb_second_xres; - u.active_dev.yres1 = viafb_second_yres; - - u.active_dev.bpp = viafb_bpp; - u.active_dev.bpp1 = viafb_bpp1; - u.active_dev.refresh = viafb_refresh; - u.active_dev.refresh1 = viafb_refresh1; - - u.active_dev.epia_dvi = viafb_platform_epia_dvi; - u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge; - u.active_dev.bus_width = viafb_bus_width; - - if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev))) - return -EFAULT; - break; - - case VIAFB_GET_DRIVER_VERSION: - u.driver_version.iMajorNum = VERSION_MAJOR; - u.driver_version.iKernelNum = VERSION_KERNEL; - u.driver_version.iOSNum = VERSION_OS; - u.driver_version.iMinorNum = VERSION_MINOR; - - if (copy_to_user(argp, &u.driver_version, - sizeof(u.driver_version))) - return -EFAULT; - - break; - - case VIAFB_GET_DEVICE_INFO: - - retrieve_device_setting(&u.viafb_setting); - - if (copy_to_user(argp, &u.viafb_setting, - sizeof(u.viafb_setting))) - return -EFAULT; - - break; - - case VIAFB_GET_DEVICE_SUPPORT: - viafb_get_device_support_state(&state_info); - if (put_user(state_info, argp)) - return -EFAULT; - break; - - case VIAFB_GET_DEVICE_CONNECT: - viafb_get_device_connect_state(&state_info); - if (put_user(state_info, argp)) - return -EFAULT; - break; - - case VIAFB_GET_PANEL_SUPPORT_EXPAND: - state_info = - viafb_lcd_get_support_expand_state(info->var.xres, - info->var.yres); - if (put_user(state_info, argp)) - return -EFAULT; - break; - - case VIAFB_GET_DRIVER_NAME: - if (copy_to_user(argp, driver_name, sizeof(driver_name))) - return -EFAULT; - break; - - case VIAFB_SET_GAMMA_LUT: - viafb_gamma_table = memdup_user(argp, 256 * sizeof(u32)); - if (IS_ERR(viafb_gamma_table)) - return PTR_ERR(viafb_gamma_table); - viafb_set_gamma_table(viafb_bpp, viafb_gamma_table); - kfree(viafb_gamma_table); - break; - - case VIAFB_GET_GAMMA_LUT: - viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL); - if (!viafb_gamma_table) - return -ENOMEM; - viafb_get_gamma_table(viafb_gamma_table); - if (copy_to_user(argp, viafb_gamma_table, - 256 * sizeof(u32))) { - kfree(viafb_gamma_table); - return -EFAULT; - } - kfree(viafb_gamma_table); - break; - - case VIAFB_GET_GAMMA_SUPPORT_STATE: - viafb_get_gamma_support_state(viafb_bpp, &state_info); - if (put_user(state_info, argp)) - return -EFAULT; - break; - case VIAFB_SYNC_SURFACE: - DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n"); - break; - case VIAFB_GET_DRIVER_CAPS: - break; - - case VIAFB_GET_PANEL_MAX_SIZE: - if (copy_from_user(&u.panel_pos_size_para, argp, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; - if (copy_to_user(argp, &u.panel_pos_size_para, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - break; - case VIAFB_GET_PANEL_MAX_POSITION: - if (copy_from_user(&u.panel_pos_size_para, argp, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; - if (copy_to_user(argp, &u.panel_pos_size_para, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - break; - - case VIAFB_GET_PANEL_POSITION: - if (copy_from_user(&u.panel_pos_size_para, argp, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; - if (copy_to_user(argp, &u.panel_pos_size_para, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - break; - case VIAFB_GET_PANEL_SIZE: - if (copy_from_user(&u.panel_pos_size_para, argp, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; - if (copy_to_user(argp, &u.panel_pos_size_para, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - break; - - case VIAFB_SET_PANEL_POSITION: - if (copy_from_user(&u.panel_pos_size_para, argp, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - break; - case VIAFB_SET_PANEL_SIZE: - if (copy_from_user(&u.panel_pos_size_para, argp, - sizeof(u.panel_pos_size_para))) - return -EFAULT; - break; - - default: - return -EINVAL; - } - - return 0; -} - -static void viafb_fillrect(struct fb_info *info, - const struct fb_fillrect *rect) -{ - struct viafb_par *viapar = info->par; - struct viafb_shared *shared = viapar->shared; - u32 fg_color; - u8 rop; - - if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) { - cfb_fillrect(info, rect); - return; - } - - if (!rect->width || !rect->height) - return; - - if (info->fix.visual == FB_VISUAL_TRUECOLOR) - fg_color = ((u32 *)info->pseudo_palette)[rect->color]; - else - fg_color = rect->color; - - if (rect->rop == ROP_XOR) - rop = 0x5A; - else - rop = 0xF0; - - DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n"); - if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_FILL, - rect->width, rect->height, info->var.bits_per_pixel, - viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy, - NULL, 0, 0, 0, 0, fg_color, 0, rop)) - cfb_fillrect(info, rect); -} - -static void viafb_copyarea(struct fb_info *info, - const struct fb_copyarea *area) -{ - struct viafb_par *viapar = info->par; - struct viafb_shared *shared = viapar->shared; - - if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) { - cfb_copyarea(info, area); - return; - } - - if (!area->width || !area->height) - return; - - DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n"); - if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_COLOR, - area->width, area->height, info->var.bits_per_pixel, - viapar->vram_addr, info->fix.line_length, area->dx, area->dy, - NULL, viapar->vram_addr, info->fix.line_length, - area->sx, area->sy, 0, 0, 0)) - cfb_copyarea(info, area); -} - -static void viafb_imageblit(struct fb_info *info, - const struct fb_image *image) -{ - struct viafb_par *viapar = info->par; - struct viafb_shared *shared = viapar->shared; - u32 fg_color = 0, bg_color = 0; - u8 op; - - if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt || - (image->depth != 1 && image->depth != viapar->depth)) { - cfb_imageblit(info, image); - return; - } - - if (image->depth == 1) { - op = VIA_BITBLT_MONO; - if (info->fix.visual == FB_VISUAL_TRUECOLOR) { - fg_color = - ((u32 *)info->pseudo_palette)[image->fg_color]; - bg_color = - ((u32 *)info->pseudo_palette)[image->bg_color]; - } else { - fg_color = image->fg_color; - bg_color = image->bg_color; - } - } else - op = VIA_BITBLT_COLOR; - - DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n"); - if (shared->hw_bitblt(shared->vdev->engine_mmio, op, - image->width, image->height, info->var.bits_per_pixel, - viapar->vram_addr, info->fix.line_length, image->dx, image->dy, - (u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0)) - cfb_imageblit(info, image); -} - -static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor) -{ - struct viafb_par *viapar = info->par; - void __iomem *engine = viapar->shared->vdev->engine_mmio; - u32 temp, xx, yy, bg_color = 0, fg_color = 0, - chip_name = viapar->shared->chip_info.gfx_chip_name; - int i, j = 0, cur_size = 64; - - if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo) - return -ENODEV; - - /* LCD ouput does not support hw cursors (at least on VN896) */ - if ((chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2) || - viafb_LCD_ON) - return -ENODEV; - - viafb_show_hw_cursor(info, HW_Cursor_OFF); - - if (cursor->set & FB_CUR_SETHOT) { - temp = (cursor->hot.x << 16) + cursor->hot.y; - writel(temp, engine + VIA_REG_CURSOR_ORG); - } - - if (cursor->set & FB_CUR_SETPOS) { - yy = cursor->image.dy - info->var.yoffset; - xx = cursor->image.dx - info->var.xoffset; - temp = yy & 0xFFFF; - temp |= (xx << 16); - writel(temp, engine + VIA_REG_CURSOR_POS); - } - - if (cursor->image.width <= 32 && cursor->image.height <= 32) - cur_size = 32; - else if (cursor->image.width <= 64 && cursor->image.height <= 64) - cur_size = 64; - else { - printk(KERN_WARNING "viafb_cursor: The cursor is too large " - "%dx%d", cursor->image.width, cursor->image.height); - return -ENXIO; - } - - if (cursor->set & FB_CUR_SETSIZE) { - temp = readl(engine + VIA_REG_CURSOR_MODE); - if (cur_size == 32) - temp |= 0x2; - else - temp &= ~0x2; - - writel(temp, engine + VIA_REG_CURSOR_MODE); - } - - if (cursor->set & FB_CUR_SETCMAP) { - fg_color = cursor->image.fg_color; - bg_color = cursor->image.bg_color; - if (chip_name == UNICHROME_CX700 || - chip_name == UNICHROME_VX800 || - chip_name == UNICHROME_VX855 || - chip_name == UNICHROME_VX900) { - fg_color = - ((info->cmap.red[fg_color] & 0xFFC0) << 14) | - ((info->cmap.green[fg_color] & 0xFFC0) << 4) | - ((info->cmap.blue[fg_color] & 0xFFC0) >> 6); - bg_color = - ((info->cmap.red[bg_color] & 0xFFC0) << 14) | - ((info->cmap.green[bg_color] & 0xFFC0) << 4) | - ((info->cmap.blue[bg_color] & 0xFFC0) >> 6); - } else { - fg_color = - ((info->cmap.red[fg_color] & 0xFF00) << 8) | - (info->cmap.green[fg_color] & 0xFF00) | - ((info->cmap.blue[fg_color] & 0xFF00) >> 8); - bg_color = - ((info->cmap.red[bg_color] & 0xFF00) << 8) | - (info->cmap.green[bg_color] & 0xFF00) | - ((info->cmap.blue[bg_color] & 0xFF00) >> 8); - } - - writel(bg_color, engine + VIA_REG_CURSOR_BG); - writel(fg_color, engine + VIA_REG_CURSOR_FG); - } - - if (cursor->set & FB_CUR_SETSHAPE) { - struct { - u8 data[CURSOR_SIZE]; - u32 bak[CURSOR_SIZE / 4]; - } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC); - int size = ((cursor->image.width + 7) >> 3) * - cursor->image.height; - - if (!cr_data) - return -ENOMEM; - - if (cur_size == 32) { - for (i = 0; i < (CURSOR_SIZE / 4); i++) { - cr_data->bak[i] = 0x0; - cr_data->bak[i + 1] = 0xFFFFFFFF; - i += 1; - } - } else { - for (i = 0; i < (CURSOR_SIZE / 4); i++) { - cr_data->bak[i] = 0x0; - cr_data->bak[i + 1] = 0x0; - cr_data->bak[i + 2] = 0xFFFFFFFF; - cr_data->bak[i + 3] = 0xFFFFFFFF; - i += 3; - } - } - - switch (cursor->rop) { - case ROP_XOR: - for (i = 0; i < size; i++) - cr_data->data[i] = cursor->mask[i]; - break; - case ROP_COPY: - - for (i = 0; i < size; i++) - cr_data->data[i] = cursor->mask[i]; - break; - default: - break; - } - - if (cur_size == 32) { - for (i = 0; i < size; i++) { - cr_data->bak[j] = (u32) cr_data->data[i]; - cr_data->bak[j + 1] = ~cr_data->bak[j]; - j += 2; - } - } else { - for (i = 0; i < size; i++) { - cr_data->bak[j] = (u32) cr_data->data[i]; - cr_data->bak[j + 1] = 0x0; - cr_data->bak[j + 2] = ~cr_data->bak[j]; - cr_data->bak[j + 3] = ~cr_data->bak[j + 1]; - j += 4; - } - } - - memcpy_toio(viafbinfo->screen_base + viapar->shared-> - cursor_vram_addr, cr_data->bak, CURSOR_SIZE); - kfree(cr_data); - } - - if (cursor->enable) - viafb_show_hw_cursor(info, HW_Cursor_ON); - - return 0; -} - -static int viafb_sync(struct fb_info *info) -{ - if (!(info->flags & FBINFO_HWACCEL_DISABLED)) - viafb_wait_engine_idle(info); - return 0; -} - -static int get_primary_device(void) -{ - int primary_device = 0; - /* Rule: device on iga1 path are the primary device. */ - if (viafb_SAMM_ON) { - if (viafb_CRT_ON) { - if (viaparinfo->crt_setting_info->iga_path == IGA1) { - DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n", - viaparinfo-> - crt_setting_info->iga_path); - primary_device = CRT_Device; - } - } - if (viafb_DVI_ON) { - if (viaparinfo->tmds_setting_info->iga_path == IGA1) { - DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n", - viaparinfo-> - tmds_setting_info->iga_path); - primary_device = DVI_Device; - } - } - if (viafb_LCD_ON) { - if (viaparinfo->lvds_setting_info->iga_path == IGA1) { - DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n", - viaparinfo-> - lvds_setting_info->iga_path); - primary_device = LCD_Device; - } - } - if (viafb_LCD2_ON) { - if (viaparinfo->lvds_setting_info2->iga_path == IGA1) { - DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n", - viaparinfo-> - lvds_setting_info2->iga_path); - primary_device = LCD2_Device; - } - } - } - return primary_device; -} - -static void retrieve_device_setting(struct viafb_ioctl_setting - *setting_info) -{ - - /* get device status */ - if (viafb_CRT_ON == 1) - setting_info->device_status = CRT_Device; - if (viafb_DVI_ON == 1) - setting_info->device_status |= DVI_Device; - if (viafb_LCD_ON == 1) - setting_info->device_status |= LCD_Device; - if (viafb_LCD2_ON == 1) - setting_info->device_status |= LCD2_Device; - - setting_info->samm_status = viafb_SAMM_ON; - setting_info->primary_device = get_primary_device(); - - setting_info->first_dev_bpp = viafb_bpp; - setting_info->second_dev_bpp = viafb_bpp1; - - setting_info->first_dev_refresh = viafb_refresh; - setting_info->second_dev_refresh = viafb_refresh1; - - setting_info->first_dev_hor_res = viafb_hotplug_Xres; - setting_info->first_dev_ver_res = viafb_hotplug_Yres; - setting_info->second_dev_hor_res = viafb_second_xres; - setting_info->second_dev_ver_res = viafb_second_yres; - - /* Get lcd attributes */ - setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method; - setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id; - setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode; -} - -static int __init parse_active_dev(void) -{ - viafb_CRT_ON = STATE_OFF; - viafb_DVI_ON = STATE_OFF; - viafb_LCD_ON = STATE_OFF; - viafb_LCD2_ON = STATE_OFF; - /* 1. Modify the active status of devices. */ - /* 2. Keep the order of devices, so we can set corresponding - IGA path to devices in SAMM case. */ - /* Note: The previous of active_dev is primary device, - and the following is secondary device. */ - if (!viafb_active_dev) { - viafb_CRT_ON = STATE_ON; - viafb_SAMM_ON = STATE_OFF; - } else if (!strcmp(viafb_active_dev, "CRT+DVI")) { - /* CRT+DVI */ - viafb_CRT_ON = STATE_ON; - viafb_DVI_ON = STATE_ON; - viafb_primary_dev = CRT_Device; - } else if (!strcmp(viafb_active_dev, "DVI+CRT")) { - /* DVI+CRT */ - viafb_CRT_ON = STATE_ON; - viafb_DVI_ON = STATE_ON; - viafb_primary_dev = DVI_Device; - } else if (!strcmp(viafb_active_dev, "CRT+LCD")) { - /* CRT+LCD */ - viafb_CRT_ON = STATE_ON; - viafb_LCD_ON = STATE_ON; - viafb_primary_dev = CRT_Device; - } else if (!strcmp(viafb_active_dev, "LCD+CRT")) { - /* LCD+CRT */ - viafb_CRT_ON = STATE_ON; - viafb_LCD_ON = STATE_ON; - viafb_primary_dev = LCD_Device; - } else if (!strcmp(viafb_active_dev, "DVI+LCD")) { - /* DVI+LCD */ - viafb_DVI_ON = STATE_ON; - viafb_LCD_ON = STATE_ON; - viafb_primary_dev = DVI_Device; - } else if (!strcmp(viafb_active_dev, "LCD+DVI")) { - /* LCD+DVI */ - viafb_DVI_ON = STATE_ON; - viafb_LCD_ON = STATE_ON; - viafb_primary_dev = LCD_Device; - } else if (!strcmp(viafb_active_dev, "LCD+LCD2")) { - viafb_LCD_ON = STATE_ON; - viafb_LCD2_ON = STATE_ON; - viafb_primary_dev = LCD_Device; - } else if (!strcmp(viafb_active_dev, "LCD2+LCD")) { - viafb_LCD_ON = STATE_ON; - viafb_LCD2_ON = STATE_ON; - viafb_primary_dev = LCD2_Device; - } else if (!strcmp(viafb_active_dev, "CRT")) { - /* CRT only */ - viafb_CRT_ON = STATE_ON; - viafb_SAMM_ON = STATE_OFF; - } else if (!strcmp(viafb_active_dev, "DVI")) { - /* DVI only */ - viafb_DVI_ON = STATE_ON; - viafb_SAMM_ON = STATE_OFF; - } else if (!strcmp(viafb_active_dev, "LCD")) { - /* LCD only */ - viafb_LCD_ON = STATE_ON; - viafb_SAMM_ON = STATE_OFF; - } else - return -EINVAL; - - return 0; -} - -static int __devinit parse_port(char *opt_str, int *output_interface) -{ - if (!strncmp(opt_str, "DVP0", 4)) - *output_interface = INTERFACE_DVP0; - else if (!strncmp(opt_str, "DVP1", 4)) - *output_interface = INTERFACE_DVP1; - else if (!strncmp(opt_str, "DFP_HIGHLOW", 11)) - *output_interface = INTERFACE_DFP; - else if (!strncmp(opt_str, "DFP_HIGH", 8)) - *output_interface = INTERFACE_DFP_HIGH; - else if (!strncmp(opt_str, "DFP_LOW", 7)) - *output_interface = INTERFACE_DFP_LOW; - else - *output_interface = INTERFACE_NONE; - return 0; -} - -static void __devinit parse_lcd_port(void) -{ - parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info. - output_interface); - /*Initialize to avoid unexpected behavior */ - viaparinfo->chip_info->lvds_chip_info2.output_interface = - INTERFACE_NONE; - - DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n", - viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info. - output_interface); -} - -static void __devinit parse_dvi_port(void) -{ - parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info. - output_interface); - - DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n", - viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info. - output_interface); -} - -#ifdef CONFIG_FB_VIA_DIRECT_PROCFS - -/* - * The proc filesystem read/write function, a simple proc implement to - * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1, - * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], - * CR9B, SR65, CR97, CR99 - */ -static int viafb_dvp0_proc_show(struct seq_file *m, void *v) -{ - u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0; - dvp0_data_dri = - (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 | - (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1; - dvp0_clk_dri = - (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 | - (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2; - dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f; - seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri); - return 0; -} - -static int viafb_dvp0_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, viafb_dvp0_proc_show, NULL); -} - -static ssize_t viafb_dvp0_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) -{ - char buf[20], *value, *pbuf; - u8 reg_val = 0; - unsigned long length, i; - if (count < 1) - return -EINVAL; - length = count > 20 ? 20 : count; - if (copy_from_user(&buf[0], buffer, length)) - return -EFAULT; - buf[length - 1] = '\0'; /*Ensure end string */ - pbuf = &buf[0]; - for (i = 0; i < 3; i++) { - value = strsep(&pbuf, " "); - if (value != NULL) { - strict_strtoul(value, 0, (unsigned long *)®_val); - DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i, - reg_val); - switch (i) { - case 0: - viafb_write_reg_mask(CR96, VIACR, - reg_val, 0x0f); - break; - case 1: - viafb_write_reg_mask(SR2A, VIASR, - reg_val << 4, BIT5); - viafb_write_reg_mask(SR1B, VIASR, - reg_val << 1, BIT1); - break; - case 2: - viafb_write_reg_mask(SR2A, VIASR, - reg_val << 3, BIT4); - viafb_write_reg_mask(SR1E, VIASR, - reg_val << 2, BIT2); - break; - default: - break; - } - } else { - break; - } - } - return count; -} - -static const struct file_operations viafb_dvp0_proc_fops = { - .owner = THIS_MODULE, - .open = viafb_dvp0_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = viafb_dvp0_proc_write, -}; - -static int viafb_dvp1_proc_show(struct seq_file *m, void *v) -{ - u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0; - dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f; - dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2; - dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03; - seq_printf(m, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri); - return 0; -} - -static int viafb_dvp1_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, viafb_dvp1_proc_show, NULL); -} - -static ssize_t viafb_dvp1_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) -{ - char buf[20], *value, *pbuf; - u8 reg_val = 0; - unsigned long length, i; - if (count < 1) - return -EINVAL; - length = count > 20 ? 20 : count; - if (copy_from_user(&buf[0], buffer, length)) - return -EFAULT; - buf[length - 1] = '\0'; /*Ensure end string */ - pbuf = &buf[0]; - for (i = 0; i < 3; i++) { - value = strsep(&pbuf, " "); - if (value != NULL) { - strict_strtoul(value, 0, (unsigned long *)®_val); - switch (i) { - case 0: - viafb_write_reg_mask(CR9B, VIACR, - reg_val, 0x0f); - break; - case 1: - viafb_write_reg_mask(SR65, VIASR, - reg_val << 2, 0x0c); - break; - case 2: - viafb_write_reg_mask(SR65, VIASR, - reg_val, 0x03); - break; - default: - break; - } - } else { - break; - } - } - return count; -} - -static const struct file_operations viafb_dvp1_proc_fops = { - .owner = THIS_MODULE, - .open = viafb_dvp1_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = viafb_dvp1_proc_write, -}; - -static int viafb_dfph_proc_show(struct seq_file *m, void *v) -{ - u8 dfp_high = 0; - dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f; - seq_printf(m, "%x\n", dfp_high); - return 0; -} - -static int viafb_dfph_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, viafb_dfph_proc_show, NULL); -} - -static ssize_t viafb_dfph_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) -{ - char buf[20]; - u8 reg_val = 0; - unsigned long length; - if (count < 1) - return -EINVAL; - length = count > 20 ? 20 : count; - if (copy_from_user(&buf[0], buffer, length)) - return -EFAULT; - buf[length - 1] = '\0'; /*Ensure end string */ - strict_strtoul(&buf[0], 0, (unsigned long *)®_val); - viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f); - return count; -} - -static const struct file_operations viafb_dfph_proc_fops = { - .owner = THIS_MODULE, - .open = viafb_dfph_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = viafb_dfph_proc_write, -}; - -static int viafb_dfpl_proc_show(struct seq_file *m, void *v) -{ - u8 dfp_low = 0; - dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f; - seq_printf(m, "%x\n", dfp_low); - return 0; -} - -static int viafb_dfpl_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, viafb_dfpl_proc_show, NULL); -} - -static ssize_t viafb_dfpl_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) -{ - char buf[20]; - u8 reg_val = 0; - unsigned long length; - if (count < 1) - return -EINVAL; - length = count > 20 ? 20 : count; - if (copy_from_user(&buf[0], buffer, length)) - return -EFAULT; - buf[length - 1] = '\0'; /*Ensure end string */ - strict_strtoul(&buf[0], 0, (unsigned long *)®_val); - viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f); - return count; -} - -static const struct file_operations viafb_dfpl_proc_fops = { - .owner = THIS_MODULE, - .open = viafb_dfpl_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = viafb_dfpl_proc_write, -}; - -static int viafb_vt1636_proc_show(struct seq_file *m, void *v) -{ - u8 vt1636_08 = 0, vt1636_09 = 0; - switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { - case VT1636_LVDS: - vt1636_08 = - viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f; - vt1636_09 = - viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info, - &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f; - seq_printf(m, "%x %x\n", vt1636_08, vt1636_09); - break; - default: - break; - } - switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { - case VT1636_LVDS: - vt1636_08 = - viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2, - &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f; - vt1636_09 = - viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2, - &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f; - seq_printf(m, " %x %x\n", vt1636_08, vt1636_09); - break; - default: - break; - } - return 0; -} - -static int viafb_vt1636_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, viafb_vt1636_proc_show, NULL); -} - -static ssize_t viafb_vt1636_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) -{ - char buf[30], *value, *pbuf; - struct IODATA reg_val; - unsigned long length, i; - if (count < 1) - return -EINVAL; - length = count > 30 ? 30 : count; - if (copy_from_user(&buf[0], buffer, length)) - return -EFAULT; - buf[length - 1] = '\0'; /*Ensure end string */ - pbuf = &buf[0]; - switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { - case VT1636_LVDS: - for (i = 0; i < 2; i++) { - value = strsep(&pbuf, " "); - if (value != NULL) { - strict_strtoul(value, 0, - (unsigned long *)®_val.Data); - switch (i) { - case 0: - reg_val.Index = 0x08; - reg_val.Mask = 0x0f; - viafb_gpio_i2c_write_mask_lvds - (viaparinfo->lvds_setting_info, - &viaparinfo-> - chip_info->lvds_chip_info, - reg_val); - break; - case 1: - reg_val.Index = 0x09; - reg_val.Mask = 0x1f; - viafb_gpio_i2c_write_mask_lvds - (viaparinfo->lvds_setting_info, - &viaparinfo-> - chip_info->lvds_chip_info, - reg_val); - break; - default: - break; - } - } else { - break; - } - } - break; - default: - break; - } - switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { - case VT1636_LVDS: - for (i = 0; i < 2; i++) { - value = strsep(&pbuf, " "); - if (value != NULL) { - strict_strtoul(value, 0, - (unsigned long *)®_val.Data); - switch (i) { - case 0: - reg_val.Index = 0x08; - reg_val.Mask = 0x0f; - viafb_gpio_i2c_write_mask_lvds - (viaparinfo->lvds_setting_info2, - &viaparinfo-> - chip_info->lvds_chip_info2, - reg_val); - break; - case 1: - reg_val.Index = 0x09; - reg_val.Mask = 0x1f; - viafb_gpio_i2c_write_mask_lvds - (viaparinfo->lvds_setting_info2, - &viaparinfo-> - chip_info->lvds_chip_info2, - reg_val); - break; - default: - break; - } - } else { - break; - } - } - break; - default: - break; - } - return count; -} - -static const struct file_operations viafb_vt1636_proc_fops = { - .owner = THIS_MODULE, - .open = viafb_vt1636_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = viafb_vt1636_proc_write, -}; - -#endif /* CONFIG_FB_VIA_DIRECT_PROCFS */ - -static int viafb_sup_odev_proc_show(struct seq_file *m, void *v) -{ - via_odev_to_seq(m, supported_odev_map[ - viaparinfo->shared->chip_info.gfx_chip_name]); - return 0; -} - -static int viafb_sup_odev_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, viafb_sup_odev_proc_show, NULL); -} - -static const struct file_operations viafb_sup_odev_proc_fops = { - .owner = THIS_MODULE, - .open = viafb_sup_odev_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static ssize_t odev_update(const char __user *buffer, size_t count, u32 *odev) -{ - char buf[64], *ptr = buf; - u32 devices; - bool add, sub; - - if (count < 1 || count > 63) - return -EINVAL; - if (copy_from_user(&buf[0], buffer, count)) - return -EFAULT; - buf[count] = '\0'; - add = buf[0] == '+'; - sub = buf[0] == '-'; - if (add || sub) - ptr++; - devices = via_parse_odev(ptr, &ptr); - if (*ptr == '\n') - ptr++; - if (*ptr != 0) - return -EINVAL; - if (add) - *odev |= devices; - else if (sub) - *odev &= ~devices; - else - *odev = devices; - return count; -} - -static int viafb_iga1_odev_proc_show(struct seq_file *m, void *v) -{ - via_odev_to_seq(m, viaparinfo->shared->iga1_devices); - return 0; -} - -static int viafb_iga1_odev_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, viafb_iga1_odev_proc_show, NULL); -} - -static ssize_t viafb_iga1_odev_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) -{ - u32 dev_on, dev_off, dev_old, dev_new; - ssize_t res; - - dev_old = dev_new = viaparinfo->shared->iga1_devices; - res = odev_update(buffer, count, &dev_new); - if (res != count) - return res; - dev_off = dev_old & ~dev_new; - dev_on = dev_new & ~dev_old; - viaparinfo->shared->iga1_devices = dev_new; - viaparinfo->shared->iga2_devices &= ~dev_new; - via_set_state(dev_off, VIA_STATE_OFF); - via_set_source(dev_new, IGA1); - via_set_state(dev_on, VIA_STATE_ON); - return res; -} - -static const struct file_operations viafb_iga1_odev_proc_fops = { - .owner = THIS_MODULE, - .open = viafb_iga1_odev_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = viafb_iga1_odev_proc_write, -}; - -static int viafb_iga2_odev_proc_show(struct seq_file *m, void *v) -{ - via_odev_to_seq(m, viaparinfo->shared->iga2_devices); - return 0; -} - -static int viafb_iga2_odev_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, viafb_iga2_odev_proc_show, NULL); -} - -static ssize_t viafb_iga2_odev_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) -{ - u32 dev_on, dev_off, dev_old, dev_new; - ssize_t res; - - dev_old = dev_new = viaparinfo->shared->iga2_devices; - res = odev_update(buffer, count, &dev_new); - if (res != count) - return res; - dev_off = dev_old & ~dev_new; - dev_on = dev_new & ~dev_old; - viaparinfo->shared->iga2_devices = dev_new; - viaparinfo->shared->iga1_devices &= ~dev_new; - via_set_state(dev_off, VIA_STATE_OFF); - via_set_source(dev_new, IGA2); - via_set_state(dev_on, VIA_STATE_ON); - return res; -} - -static const struct file_operations viafb_iga2_odev_proc_fops = { - .owner = THIS_MODULE, - .open = viafb_iga2_odev_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = viafb_iga2_odev_proc_write, -}; - -#define IS_VT1636(lvds_chip) ((lvds_chip).lvds_chip_name == VT1636_LVDS) -static void viafb_init_proc(struct viafb_shared *shared) -{ - struct proc_dir_entry *iga1_entry, *iga2_entry, - *viafb_entry = proc_mkdir("viafb", NULL); - - shared->proc_entry = viafb_entry; - if (viafb_entry) { -#ifdef CONFIG_FB_VIA_DIRECT_PROCFS - proc_create("dvp0", 0, viafb_entry, &viafb_dvp0_proc_fops); - proc_create("dvp1", 0, viafb_entry, &viafb_dvp1_proc_fops); - proc_create("dfph", 0, viafb_entry, &viafb_dfph_proc_fops); - proc_create("dfpl", 0, viafb_entry, &viafb_dfpl_proc_fops); - if (IS_VT1636(shared->chip_info.lvds_chip_info) - || IS_VT1636(shared->chip_info.lvds_chip_info2)) - proc_create("vt1636", 0, viafb_entry, - &viafb_vt1636_proc_fops); -#endif /* CONFIG_FB_VIA_DIRECT_PROCFS */ - - proc_create("supported_output_devices", 0, viafb_entry, - &viafb_sup_odev_proc_fops); - iga1_entry = proc_mkdir("iga1", viafb_entry); - shared->iga1_proc_entry = iga1_entry; - proc_create("output_devices", 0, iga1_entry, - &viafb_iga1_odev_proc_fops); - iga2_entry = proc_mkdir("iga2", viafb_entry); - shared->iga2_proc_entry = iga2_entry; - proc_create("output_devices", 0, iga2_entry, - &viafb_iga2_odev_proc_fops); - } -} -static void viafb_remove_proc(struct viafb_shared *shared) -{ - struct proc_dir_entry *viafb_entry = shared->proc_entry, - *iga1_entry = shared->iga1_proc_entry, - *iga2_entry = shared->iga2_proc_entry; - - if (!viafb_entry) - return; - - remove_proc_entry("output_devices", iga2_entry); - remove_proc_entry("iga2", viafb_entry); - remove_proc_entry("output_devices", iga1_entry); - remove_proc_entry("iga1", viafb_entry); - remove_proc_entry("supported_output_devices", viafb_entry); - -#ifdef CONFIG_FB_VIA_DIRECT_PROCFS - remove_proc_entry("dvp0", viafb_entry);/* parent dir */ - remove_proc_entry("dvp1", viafb_entry); - remove_proc_entry("dfph", viafb_entry); - remove_proc_entry("dfpl", viafb_entry); - if (IS_VT1636(shared->chip_info.lvds_chip_info) - || IS_VT1636(shared->chip_info.lvds_chip_info2)) - remove_proc_entry("vt1636", viafb_entry); -#endif /* CONFIG_FB_VIA_DIRECT_PROCFS */ - - remove_proc_entry("viafb", NULL); -} -#undef IS_VT1636 - -static int parse_mode(const char *str, u32 *xres, u32 *yres) -{ - char *ptr; - - if (!str) { - *xres = 640; - *yres = 480; - return 0; - } - - *xres = simple_strtoul(str, &ptr, 10); - if (ptr[0] != 'x') - return -EINVAL; - - *yres = simple_strtoul(&ptr[1], &ptr, 10); - if (ptr[0]) - return -EINVAL; - - return 0; -} - - -#ifdef CONFIG_PM -static int viafb_suspend(void *unused) -{ - acquire_console_sem(); - fb_set_suspend(viafbinfo, 1); - viafb_sync(viafbinfo); - release_console_sem(); - - return 0; -} - -static int viafb_resume(void *unused) -{ - acquire_console_sem(); - if (viaparinfo->shared->vdev->engine_mmio) - viafb_reset_engine(viaparinfo); - viafb_set_par(viafbinfo); - if (viafb_dual_fb) - viafb_set_par(viafbinfo1); - fb_set_suspend(viafbinfo, 0); - - release_console_sem(); - return 0; -} - -static struct viafb_pm_hooks viafb_fb_pm_hooks = { - .suspend = viafb_suspend, - .resume = viafb_resume -}; - -#endif - - -int __devinit via_fb_pci_probe(struct viafb_dev *vdev) -{ - u32 default_xres, default_yres; - struct VideoModeTable *vmode_entry; - struct fb_var_screeninfo default_var; - int rc; - u32 viafb_par_length; - - DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n"); - memset(&default_var, 0, sizeof(default_var)); - viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8); - - /* Allocate fb_info and ***_par here, also including some other needed - * variables - */ - viafbinfo = framebuffer_alloc(viafb_par_length + - ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8), - &vdev->pdev->dev); - if (!viafbinfo) { - printk(KERN_ERR"Could not allocate memory for viafb_info.\n"); - return -ENOMEM; - } - - viaparinfo = (struct viafb_par *)viafbinfo->par; - viaparinfo->shared = viafbinfo->par + viafb_par_length; - viaparinfo->shared->vdev = vdev; - viaparinfo->vram_addr = 0; - viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info; - viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info; - viaparinfo->lvds_setting_info2 = - &viaparinfo->shared->lvds_setting_info2; - viaparinfo->crt_setting_info = &viaparinfo->shared->crt_setting_info; - viaparinfo->chip_info = &viaparinfo->shared->chip_info; - - if (viafb_dual_fb) - viafb_SAMM_ON = 1; - parse_lcd_port(); - parse_dvi_port(); - - viafb_init_chip_info(vdev->chip_type); - /* - * The framebuffer will have been successfully mapped by - * the core (or we'd not be here), but we still need to - * set up our own accounting. - */ - viaparinfo->fbmem = vdev->fbmem_start; - viaparinfo->memsize = vdev->fbmem_len; - viaparinfo->fbmem_free = viaparinfo->memsize; - viaparinfo->fbmem_used = 0; - viafbinfo->screen_base = vdev->fbmem; - - viafbinfo->fix.mmio_start = vdev->engine_start; - viafbinfo->fix.mmio_len = vdev->engine_len; - viafbinfo->node = 0; - viafbinfo->fbops = &viafb_ops; - viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; - - viafbinfo->pseudo_palette = pseudo_pal; - if (viafb_accel && !viafb_setup_engine(viafbinfo)) { - viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA | - FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT; - default_var.accel_flags = FB_ACCELF_TEXT; - } else { - viafbinfo->flags |= FBINFO_HWACCEL_DISABLED; - default_var.accel_flags = 0; - } - - if (viafb_second_size && (viafb_second_size < 8)) { - viafb_second_offset = viaparinfo->fbmem_free - - viafb_second_size * 1024 * 1024; - } else { - viafb_second_size = 8; - viafb_second_offset = viaparinfo->fbmem_free - - viafb_second_size * 1024 * 1024; - } - - parse_mode(viafb_mode, &default_xres, &default_yres); - vmode_entry = viafb_get_mode(default_xres, default_yres); - if (viafb_SAMM_ON == 1) { - parse_mode(viafb_mode1, &viafb_second_xres, - &viafb_second_yres); - - viafb_second_virtual_xres = viafb_second_xres; - viafb_second_virtual_yres = viafb_second_yres; - } - - default_var.xres = default_xres; - default_var.yres = default_yres; - default_var.xres_virtual = default_xres; - default_var.yres_virtual = default_yres; - default_var.bits_per_pixel = viafb_bpp; - default_var.pixclock = - viafb_get_pixclock(default_xres, default_yres, viafb_refresh); - default_var.left_margin = (default_xres >> 3) & 0xf8; - default_var.right_margin = 32; - default_var.upper_margin = 16; - default_var.lower_margin = 4; - default_var.hsync_len = default_var.left_margin; - default_var.vsync_len = 4; - viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo); - viafbinfo->var = default_var; - - if (viafb_dual_fb) { - viafbinfo1 = framebuffer_alloc(viafb_par_length, - &vdev->pdev->dev); - if (!viafbinfo1) { - printk(KERN_ERR - "allocate the second framebuffer struct error\n"); - rc = -ENOMEM; - goto out_fb_release; - } - viaparinfo1 = viafbinfo1->par; - memcpy(viaparinfo1, viaparinfo, viafb_par_length); - viaparinfo1->vram_addr = viafb_second_offset; - viaparinfo1->memsize = viaparinfo->memsize - - viafb_second_offset; - viaparinfo->memsize = viafb_second_offset; - viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset; - - viaparinfo1->fbmem_used = viaparinfo->fbmem_used; - viaparinfo1->fbmem_free = viaparinfo1->memsize - - viaparinfo1->fbmem_used; - viaparinfo->fbmem_free = viaparinfo->memsize; - viaparinfo->fbmem_used = 0; - - viaparinfo->iga_path = IGA1; - viaparinfo1->iga_path = IGA2; - memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info)); - viafbinfo1->par = viaparinfo1; - viafbinfo1->screen_base = viafbinfo->screen_base + - viafb_second_offset; - - default_var.xres = viafb_second_xres; - default_var.yres = viafb_second_yres; - default_var.xres_virtual = viafb_second_virtual_xres; - default_var.yres_virtual = viafb_second_virtual_yres; - default_var.bits_per_pixel = viafb_bpp1; - default_var.pixclock = - viafb_get_pixclock(viafb_second_xres, viafb_second_yres, - viafb_refresh); - default_var.left_margin = (viafb_second_xres >> 3) & 0xf8; - default_var.right_margin = 32; - default_var.upper_margin = 16; - default_var.lower_margin = 4; - default_var.hsync_len = default_var.left_margin; - default_var.vsync_len = 4; - - viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1); - viafb_check_var(&default_var, viafbinfo1); - viafbinfo1->var = default_var; - viafb_update_fix(viafbinfo1); - viaparinfo1->depth = fb_get_color_depth(&viafbinfo1->var, - &viafbinfo1->fix); - } - - viafb_check_var(&viafbinfo->var, viafbinfo); - viafb_update_fix(viafbinfo); - viaparinfo->depth = fb_get_color_depth(&viafbinfo->var, - &viafbinfo->fix); - default_var.activate = FB_ACTIVATE_NOW; - rc = fb_alloc_cmap(&viafbinfo->cmap, 256, 0); - if (rc) - goto out_fb1_release; - - if (viafb_dual_fb && (viafb_primary_dev == LCD_Device) - && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) { - rc = register_framebuffer(viafbinfo1); - if (rc) - goto out_dealloc_cmap; - } - rc = register_framebuffer(viafbinfo); - if (rc) - goto out_fb1_unreg_lcd_cle266; - - if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device) - || (viaparinfo->chip_info->gfx_chip_name != - UNICHROME_CLE266))) { - rc = register_framebuffer(viafbinfo1); - if (rc) - goto out_fb_unreg; - } - DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n", - viafbinfo->node, viafbinfo->fix.id, default_var.xres, - default_var.yres, default_var.bits_per_pixel); - - viafb_init_proc(viaparinfo->shared); - viafb_init_dac(IGA2); - -#ifdef CONFIG_PM - viafb_pm_register(&viafb_fb_pm_hooks); -#endif - return 0; - -out_fb_unreg: - unregister_framebuffer(viafbinfo); -out_fb1_unreg_lcd_cle266: - if (viafb_dual_fb && (viafb_primary_dev == LCD_Device) - && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) - unregister_framebuffer(viafbinfo1); -out_dealloc_cmap: - fb_dealloc_cmap(&viafbinfo->cmap); -out_fb1_release: - if (viafbinfo1) - framebuffer_release(viafbinfo1); -out_fb_release: - framebuffer_release(viafbinfo); - return rc; -} - -void __devexit via_fb_pci_remove(struct pci_dev *pdev) -{ - DEBUG_MSG(KERN_INFO "via_pci_remove!\n"); - fb_dealloc_cmap(&viafbinfo->cmap); - unregister_framebuffer(viafbinfo); - if (viafb_dual_fb) - unregister_framebuffer(viafbinfo1); - viafb_remove_proc(viaparinfo->shared); - framebuffer_release(viafbinfo); - if (viafb_dual_fb) - framebuffer_release(viafbinfo1); -} - -#ifndef MODULE -static int __init viafb_setup(char *options) -{ - char *this_opt; - DEBUG_MSG(KERN_INFO "viafb_setup!\n"); - - if (!options || !*options) - return 0; - - while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) - continue; - - if (!strncmp(this_opt, "viafb_mode1=", 12)) - viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL); - else if (!strncmp(this_opt, "viafb_mode=", 11)) - viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL); - else if (!strncmp(this_opt, "viafb_bpp1=", 11)) - strict_strtoul(this_opt + 11, 0, - (unsigned long *)&viafb_bpp1); - else if (!strncmp(this_opt, "viafb_bpp=", 10)) - strict_strtoul(this_opt + 10, 0, - (unsigned long *)&viafb_bpp); - else if (!strncmp(this_opt, "viafb_refresh1=", 15)) - strict_strtoul(this_opt + 15, 0, - (unsigned long *)&viafb_refresh1); - else if (!strncmp(this_opt, "viafb_refresh=", 14)) - strict_strtoul(this_opt + 14, 0, - (unsigned long *)&viafb_refresh); - else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21)) - strict_strtoul(this_opt + 21, 0, - (unsigned long *)&viafb_lcd_dsp_method); - else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19)) - strict_strtoul(this_opt + 19, 0, - (unsigned long *)&viafb_lcd_panel_id); - else if (!strncmp(this_opt, "viafb_accel=", 12)) - strict_strtoul(this_opt + 12, 0, - (unsigned long *)&viafb_accel); - else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14)) - strict_strtoul(this_opt + 14, 0, - (unsigned long *)&viafb_SAMM_ON); - else if (!strncmp(this_opt, "viafb_active_dev=", 17)) - viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL); - else if (!strncmp(this_opt, - "viafb_display_hardware_layout=", 30)) - strict_strtoul(this_opt + 30, 0, - (unsigned long *)&viafb_display_hardware_layout); - else if (!strncmp(this_opt, "viafb_second_size=", 18)) - strict_strtoul(this_opt + 18, 0, - (unsigned long *)&viafb_second_size); - else if (!strncmp(this_opt, - "viafb_platform_epia_dvi=", 24)) - strict_strtoul(this_opt + 24, 0, - (unsigned long *)&viafb_platform_epia_dvi); - else if (!strncmp(this_opt, - "viafb_device_lcd_dualedge=", 26)) - strict_strtoul(this_opt + 26, 0, - (unsigned long *)&viafb_device_lcd_dualedge); - else if (!strncmp(this_opt, "viafb_bus_width=", 16)) - strict_strtoul(this_opt + 16, 0, - (unsigned long *)&viafb_bus_width); - else if (!strncmp(this_opt, "viafb_lcd_mode=", 15)) - strict_strtoul(this_opt + 15, 0, - (unsigned long *)&viafb_lcd_mode); - else if (!strncmp(this_opt, "viafb_lcd_port=", 15)) - viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL); - else if (!strncmp(this_opt, "viafb_dvi_port=", 15)) - viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL); - } - return 0; -} -#endif - -/* - * These are called out of via-core for now. - */ -int __init viafb_init(void) -{ - u32 dummy; -#ifndef MODULE - char *option = NULL; - if (fb_get_options("viafb", &option)) - return -ENODEV; - viafb_setup(option); -#endif - if (parse_mode(viafb_mode, &dummy, &dummy) - || parse_mode(viafb_mode1, &dummy, &dummy) - || viafb_bpp < 0 || viafb_bpp > 32 - || viafb_bpp1 < 0 || viafb_bpp1 > 32 - || parse_active_dev()) - return -EINVAL; - - printk(KERN_INFO - "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n", - VERSION_MAJOR, VERSION_MINOR); - return 0; -} - -void __exit viafb_exit(void) -{ - DEBUG_MSG(KERN_INFO "viafb_exit!\n"); -} - -static struct fb_ops viafb_ops = { - .owner = THIS_MODULE, - .fb_open = viafb_open, - .fb_release = viafb_release, - .fb_check_var = viafb_check_var, - .fb_set_par = viafb_set_par, - .fb_setcolreg = viafb_setcolreg, - .fb_pan_display = viafb_pan_display, - .fb_blank = viafb_blank, - .fb_fillrect = viafb_fillrect, - .fb_copyarea = viafb_copyarea, - .fb_imageblit = viafb_imageblit, - .fb_cursor = viafb_cursor, - .fb_ioctl = viafb_ioctl, - .fb_sync = viafb_sync, -}; - - -#ifdef MODULE -module_param(viafb_mode, charp, S_IRUSR); -MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)"); - -module_param(viafb_mode1, charp, S_IRUSR); -MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)"); - -module_param(viafb_bpp, int, S_IRUSR); -MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)"); - -module_param(viafb_bpp1, int, S_IRUSR); -MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)"); - -module_param(viafb_refresh, int, S_IRUSR); -MODULE_PARM_DESC(viafb_refresh, - "Set CRT viafb_refresh rate (default = 60)"); - -module_param(viafb_refresh1, int, S_IRUSR); -MODULE_PARM_DESC(viafb_refresh1, - "Set CRT refresh rate (default = 60)"); - -module_param(viafb_lcd_panel_id, int, S_IRUSR); -MODULE_PARM_DESC(viafb_lcd_panel_id, - "Set Flat Panel type(Default=1024x768)"); - -module_param(viafb_lcd_dsp_method, int, S_IRUSR); -MODULE_PARM_DESC(viafb_lcd_dsp_method, - "Set Flat Panel display scaling method.(Default=Expandsion)"); - -module_param(viafb_SAMM_ON, int, S_IRUSR); -MODULE_PARM_DESC(viafb_SAMM_ON, - "Turn on/off flag of SAMM(Default=OFF)"); - -module_param(viafb_accel, int, S_IRUSR); -MODULE_PARM_DESC(viafb_accel, - "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)"); - -module_param(viafb_active_dev, charp, S_IRUSR); -MODULE_PARM_DESC(viafb_active_dev, "Specify active devices."); - -module_param(viafb_display_hardware_layout, int, S_IRUSR); -MODULE_PARM_DESC(viafb_display_hardware_layout, - "Display Hardware Layout (LCD Only, DVI Only...,etc)"); - -module_param(viafb_second_size, int, S_IRUSR); -MODULE_PARM_DESC(viafb_second_size, - "Set secondary device memory size"); - -module_param(viafb_dual_fb, int, S_IRUSR); -MODULE_PARM_DESC(viafb_dual_fb, - "Turn on/off flag of dual framebuffer devices.(Default = OFF)"); - -module_param(viafb_platform_epia_dvi, int, S_IRUSR); -MODULE_PARM_DESC(viafb_platform_epia_dvi, - "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)"); - -module_param(viafb_device_lcd_dualedge, int, S_IRUSR); -MODULE_PARM_DESC(viafb_device_lcd_dualedge, - "Turn on/off flag of dual edge panel.(Default = OFF)"); - -module_param(viafb_bus_width, int, S_IRUSR); -MODULE_PARM_DESC(viafb_bus_width, - "Set bus width of panel.(Default = 12)"); - -module_param(viafb_lcd_mode, int, S_IRUSR); -MODULE_PARM_DESC(viafb_lcd_mode, - "Set Flat Panel mode(Default=OPENLDI)"); - -module_param(viafb_lcd_port, charp, S_IRUSR); -MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port."); - -module_param(viafb_dvi_port, charp, S_IRUSR); -MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port."); - -MODULE_LICENSE("GPL"); -#endif diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h deleted file mode 100644 index d66f963e930..00000000000 --- a/drivers/video/via/viafbdev.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 __VIAFBDEV_H__ -#define __VIAFBDEV_H__ - -#include <linux/proc_fs.h> -#include <linux/fb.h> -#include <linux/spinlock.h> - -#include "ioctl.h" -#include "share.h" -#include "chip.h" -#include "hw.h" - -#define VERSION_MAJOR 2 -#define VERSION_KERNEL 6 /* For kernel 2.6 */ - -#define VERSION_OS 0 /* 0: for 32 bits OS, 1: for 64 bits OS */ -#define VERSION_MINOR 4 - -#define VIAFB_NUM_I2C 5 - -struct viafb_shared { - u32 iga1_devices; - u32 iga2_devices; - - struct proc_dir_entry *proc_entry; /*viafb proc entry */ - struct proc_dir_entry *iga1_proc_entry; - struct proc_dir_entry *iga2_proc_entry; - struct viafb_dev *vdev; /* Global dev info */ - - /* All the information will be needed to set engine */ - struct tmds_setting_information tmds_setting_info; - struct crt_setting_information crt_setting_info; - struct lvds_setting_information lvds_setting_info; - struct lvds_setting_information lvds_setting_info2; - struct chip_information chip_info; - - /* hardware acceleration stuff */ - u32 cursor_vram_addr; - u32 vq_vram_addr; /* virtual queue address in video ram */ - int (*hw_bitblt)(void __iomem *engine, u8 op, u32 width, u32 height, - u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y, - u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y, - u32 fg_color, u32 bg_color, u8 fill_rop); -}; - -struct viafb_par { - u8 depth; - u32 vram_addr; - - unsigned int fbmem; /*framebuffer physical memory address */ - unsigned int memsize; /*size of fbmem */ - u32 fbmem_free; /* Free FB memory */ - u32 fbmem_used; /* Use FB memory size */ - u32 iga_path; - - struct viafb_shared *shared; - - /* All the information will be needed to set engine */ - /* depreciated, use the ones in shared directly */ - struct tmds_setting_information *tmds_setting_info; - struct crt_setting_information *crt_setting_info; - struct lvds_setting_information *lvds_setting_info; - struct lvds_setting_information *lvds_setting_info2; - struct chip_information *chip_info; -}; - -extern unsigned int viafb_second_virtual_yres; -extern unsigned int viafb_second_virtual_xres; -extern int viafb_SAMM_ON; -extern int viafb_dual_fb; -extern int viafb_LCD2_ON; -extern int viafb_LCD_ON; -extern int viafb_DVI_ON; -extern int viafb_hotplug; - -extern int strict_strtoul(const char *cp, unsigned int base, - unsigned long *res); - -u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information - *plvds_setting_info, struct lvds_chip_information - *plvds_chip_info, u8 index); -void viafb_gpio_i2c_write_mask_lvds(struct lvds_setting_information - *plvds_setting_info, struct lvds_chip_information - *plvds_chip_info, struct IODATA io_data); -int via_fb_pci_probe(struct viafb_dev *vdev); -void via_fb_pci_remove(struct pci_dev *pdev); -/* Temporary */ -int viafb_init(void); -void viafb_exit(void); -#endif /* __VIAFBDEV_H__ */ diff --git a/drivers/video/via/viamode.c b/drivers/video/via/viamode.c deleted file mode 100644 index 2dbad3c0f67..00000000000 --- a/drivers/video/via/viamode.c +++ /dev/null @@ -1,1093 +0,0 @@ -/* - * 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 <linux/via-core.h> -#include "global.h" -struct res_map_refresh res_map_refresh_tbl[] = { -/*hres, vres, vclock, vmode_refresh*/ - {480, 640, RES_480X640_60HZ_PIXCLOCK, 60}, - {640, 480, RES_640X480_60HZ_PIXCLOCK, 60}, - {640, 480, RES_640X480_75HZ_PIXCLOCK, 75}, - {640, 480, RES_640X480_85HZ_PIXCLOCK, 85}, - {640, 480, RES_640X480_100HZ_PIXCLOCK, 100}, - {640, 480, RES_640X480_120HZ_PIXCLOCK, 120}, - {720, 480, RES_720X480_60HZ_PIXCLOCK, 60}, - {720, 576, RES_720X576_60HZ_PIXCLOCK, 60}, - {800, 480, RES_800X480_60HZ_PIXCLOCK, 60}, - {800, 600, RES_800X600_60HZ_PIXCLOCK, 60}, - {800, 600, RES_800X600_75HZ_PIXCLOCK, 75}, - {800, 600, RES_800X600_85HZ_PIXCLOCK, 85}, - {800, 600, RES_800X600_100HZ_PIXCLOCK, 100}, - {800, 600, RES_800X600_120HZ_PIXCLOCK, 120}, - {848, 480, RES_848X480_60HZ_PIXCLOCK, 60}, - {856, 480, RES_856X480_60HZ_PIXCLOCK, 60}, - {1024, 512, RES_1024X512_60HZ_PIXCLOCK, 60}, - {1024, 600, RES_1024X600_60HZ_PIXCLOCK, 60}, - {1024, 768, RES_1024X768_60HZ_PIXCLOCK, 60}, - {1024, 768, RES_1024X768_75HZ_PIXCLOCK, 75}, - {1024, 768, RES_1024X768_85HZ_PIXCLOCK, 85}, - {1024, 768, RES_1024X768_100HZ_PIXCLOCK, 100}, -/* {1152,864, RES_1152X864_70HZ_PIXCLOCK, 70},*/ - {1152, 864, RES_1152X864_75HZ_PIXCLOCK, 75}, - {1280, 768, RES_1280X768_60HZ_PIXCLOCK, 60}, - {1280, 800, RES_1280X800_60HZ_PIXCLOCK, 60}, - {1280, 960, RES_1280X960_60HZ_PIXCLOCK, 60}, - {1280, 1024, RES_1280X1024_60HZ_PIXCLOCK, 60}, - {1280, 1024, RES_1280X1024_75HZ_PIXCLOCK, 75}, - {1280, 1024, RES_1280X768_85HZ_PIXCLOCK, 85}, - {1440, 1050, RES_1440X1050_60HZ_PIXCLOCK, 60}, - {1600, 1200, RES_1600X1200_60HZ_PIXCLOCK, 60}, - {1600, 1200, RES_1600X1200_75HZ_PIXCLOCK, 75}, - {1280, 720, RES_1280X720_60HZ_PIXCLOCK, 60}, - {1920, 1080, RES_1920X1080_60HZ_PIXCLOCK, 60}, - {1400, 1050, RES_1400X1050_60HZ_PIXCLOCK, 60}, - {1400, 1050, RES_1400X1050_75HZ_PIXCLOCK, 75}, - {1368, 768, RES_1368X768_60HZ_PIXCLOCK, 60}, - {960, 600, RES_960X600_60HZ_PIXCLOCK, 60}, - {1000, 600, RES_1000X600_60HZ_PIXCLOCK, 60}, - {1024, 576, RES_1024X576_60HZ_PIXCLOCK, 60}, - {1088, 612, RES_1088X612_60HZ_PIXCLOCK, 60}, - {1152, 720, RES_1152X720_60HZ_PIXCLOCK, 60}, - {1200, 720, RES_1200X720_60HZ_PIXCLOCK, 60}, - {1200, 900, RES_1200X900_60HZ_PIXCLOCK, 60}, - {1280, 600, RES_1280X600_60HZ_PIXCLOCK, 60}, - {1280, 720, RES_1280X720_50HZ_PIXCLOCK, 50}, - {1280, 768, RES_1280X768_50HZ_PIXCLOCK, 50}, - {1360, 768, RES_1360X768_60HZ_PIXCLOCK, 60}, - {1366, 768, RES_1366X768_50HZ_PIXCLOCK, 50}, - {1366, 768, RES_1366X768_60HZ_PIXCLOCK, 60}, - {1440, 900, RES_1440X900_60HZ_PIXCLOCK, 60}, - {1440, 900, RES_1440X900_75HZ_PIXCLOCK, 75}, - {1600, 900, RES_1600X900_60HZ_PIXCLOCK, 60}, - {1600, 1024, RES_1600X1024_60HZ_PIXCLOCK, 60}, - {1680, 1050, RES_1680X1050_60HZ_PIXCLOCK, 60}, - {1680, 1050, RES_1680X1050_75HZ_PIXCLOCK, 75}, - {1792, 1344, RES_1792X1344_60HZ_PIXCLOCK, 60}, - {1856, 1392, RES_1856X1392_60HZ_PIXCLOCK, 60}, - {1920, 1200, RES_1920X1200_60HZ_PIXCLOCK, 60}, - {1920, 1440, RES_1920X1440_60HZ_PIXCLOCK, 60}, - {1920, 1440, RES_1920X1440_75HZ_PIXCLOCK, 75}, - {2048, 1536, RES_2048X1536_60HZ_PIXCLOCK, 60} -}; - -struct io_reg CN400_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, -{VIASR, SR15, 0x02, 0x02}, -{VIASR, SR16, 0xBF, 0x08}, -{VIASR, SR17, 0xFF, 0x1F}, -{VIASR, SR18, 0xFF, 0x4E}, -{VIASR, SR1A, 0xFB, 0x08}, -{VIASR, SR1E, 0x0F, 0x01}, -{VIASR, SR2A, 0xFF, 0x00}, -{VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ -{VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ -{VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ -{VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ -{VIACR, CR32, 0xFF, 0x00}, -{VIACR, CR33, 0xFF, 0x00}, -{VIACR, CR35, 0xFF, 0x00}, -{VIACR, CR36, 0x08, 0x00}, -{VIACR, CR69, 0xFF, 0x00}, -{VIACR, CR6A, 0xFF, 0x40}, -{VIACR, CR6B, 0xFF, 0x00}, -{VIACR, CR6C, 0xFF, 0x00}, -{VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ -{VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ -{VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ -{VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ -{VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ -{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ -{VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ -{VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ -{VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ -{VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ -{VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ -{VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ -{VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ -{VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ -{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ -{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ -{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ -{VIACR, CR8B, 0xFF, 0x69}, /* LCD Power Sequence Control 0 */ -{VIACR, CR8C, 0xFF, 0x57}, /* LCD Power Sequence Control 1 */ -{VIACR, CR8D, 0xFF, 0x00}, /* LCD Power Sequence Control 2 */ -{VIACR, CR8E, 0xFF, 0x7B}, /* LCD Power Sequence Control 3 */ -{VIACR, CR8F, 0xFF, 0x03}, /* LCD Power Sequence Control 4 */ -{VIACR, CR90, 0xFF, 0x30}, /* LCD Power Sequence Control 5 */ -{VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */ -{VIACR, CR96, 0xFF, 0x00}, -{VIACR, CR97, 0xFF, 0x00}, -{VIACR, CR99, 0xFF, 0x00}, -{VIACR, CR9B, 0xFF, 0x00} -}; - -/* Video Mode Table for VT3314 chipset*/ -/* Common Setting for Video Mode */ -struct io_reg CN700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, -{VIASR, SR15, 0x02, 0x02}, -{VIASR, SR16, 0xBF, 0x08}, -{VIASR, SR17, 0xFF, 0x1F}, -{VIASR, SR18, 0xFF, 0x4E}, -{VIASR, SR1A, 0xFB, 0x82}, -{VIASR, SR1B, 0xFF, 0xF0}, -{VIASR, SR1F, 0xFF, 0x00}, -{VIASR, SR1E, 0xFF, 0x01}, -{VIASR, SR22, 0xFF, 0x1F}, -{VIASR, SR2A, 0x0F, 0x00}, -{VIASR, SR2E, 0xFF, 0xFF}, -{VIASR, SR3F, 0xFF, 0xFF}, -{VIASR, SR40, 0xF7, 0x00}, -{VIASR, CR30, 0xFF, 0x04}, -{VIACR, CR32, 0xFF, 0x00}, -{VIACR, CR33, 0x7F, 0x00}, -{VIACR, CR35, 0xFF, 0x00}, -{VIACR, CR36, 0xFF, 0x31}, -{VIACR, CR41, 0xFF, 0x80}, -{VIACR, CR42, 0xFF, 0x00}, -{VIACR, CR55, 0x80, 0x00}, -{VIACR, CR5D, 0x80, 0x00}, /*Horizontal Retrace Start bit[11] should be 0*/ -{VIACR, CR68, 0xFF, 0x67}, /* Default FIFO For IGA2 */ -{VIACR, CR69, 0xFF, 0x00}, -{VIACR, CR6A, 0xFD, 0x40}, -{VIACR, CR6B, 0xFF, 0x00}, -{VIACR, CR6C, 0xFF, 0x00}, -{VIACR, CR77, 0xFF, 0x00}, /* LCD scaling Factor */ -{VIACR, CR78, 0xFF, 0x00}, /* LCD scaling Factor */ -{VIACR, CR79, 0xFF, 0x00}, /* LCD scaling Factor */ -{VIACR, CR9F, 0x03, 0x00}, /* LCD scaling Factor */ -{VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ -{VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ -{VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ -{VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ -{VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ -{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ -{VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ -{VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ -{VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ -{VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ -{VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ -{VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ -{VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ -{VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ -{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ -{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ -{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ -{VIACR, CR8B, 0xFF, 0x5D}, /* LCD Power Sequence Control 0 */ -{VIACR, CR8C, 0xFF, 0x2B}, /* LCD Power Sequence Control 1 */ -{VIACR, CR8D, 0xFF, 0x6F}, /* LCD Power Sequence Control 2 */ -{VIACR, CR8E, 0xFF, 0x2B}, /* LCD Power Sequence Control 3 */ -{VIACR, CR8F, 0xFF, 0x01}, /* LCD Power Sequence Control 4 */ -{VIACR, CR90, 0xFF, 0x01}, /* LCD Power Sequence Control 5 */ -{VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */ -{VIACR, CR96, 0xFF, 0x00}, -{VIACR, CR97, 0xFF, 0x00}, -{VIACR, CR99, 0xFF, 0x00}, -{VIACR, CR9B, 0xFF, 0x00}, -{VIACR, CR9D, 0xFF, 0x80}, -{VIACR, CR9E, 0xFF, 0x80} -}; - -struct io_reg KM400_ModeXregs[] = { - {VIASR, SR10, 0xFF, 0x01}, /* Unlock Register */ - {VIASR, SR16, 0xFF, 0x08}, /* Display FIFO threshold Control */ - {VIASR, SR17, 0xFF, 0x1F}, /* Display FIFO Control */ - {VIASR, SR18, 0xFF, 0x4E}, /* GFX PREQ threshold */ - {VIASR, SR1A, 0xFF, 0x0a}, /* GFX PREQ threshold */ - {VIASR, SR1F, 0xFF, 0x00}, /* Memory Control 0 */ - {VIASR, SR1B, 0xFF, 0xF0}, /* Power Management Control 0 */ - {VIASR, SR1E, 0xFF, 0x01}, /* Power Management Control */ - {VIASR, SR20, 0xFF, 0x00}, /* Sequencer Arbiter Control 0 */ - {VIASR, SR21, 0xFF, 0x00}, /* Sequencer Arbiter Control 1 */ - {VIASR, SR22, 0xFF, 0x1F}, /* Display Arbiter Control 1 */ - {VIASR, SR2A, 0xFF, 0x00}, /* Power Management Control 5 */ - {VIASR, SR2D, 0xFF, 0xFF}, /* Power Management Control 1 */ - {VIASR, SR2E, 0xFF, 0xFF}, /* Power Management Control 2 */ - {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ - {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ - {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ - {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ - {VIACR, CR33, 0xFF, 0x00}, - {VIACR, CR55, 0x80, 0x00}, - {VIACR, CR5D, 0x80, 0x00}, - {VIACR, CR36, 0xFF, 0x01}, /* Power Mangement 3 */ - {VIACR, CR68, 0xFF, 0x67}, /* Default FIFO For IGA2 */ - {VIACR, CR6A, 0x20, 0x20}, /* Extended FIFO On */ - {VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ - {VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ - {VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ - {VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ - {VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ - {VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ - {VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ - {VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ - {VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ - {VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ - {VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ - {VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ - {VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ - {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ - {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ - {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ - {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ - {VIACR, CR8B, 0xFF, 0x2D}, /* LCD Power Sequence Control 0 */ - {VIACR, CR8C, 0xFF, 0x2D}, /* LCD Power Sequence Control 1 */ - {VIACR, CR8D, 0xFF, 0xC8}, /* LCD Power Sequence Control 2 */ - {VIACR, CR8E, 0xFF, 0x36}, /* LCD Power Sequence Control 3 */ - {VIACR, CR8F, 0xFF, 0x00}, /* LCD Power Sequence Control 4 */ - {VIACR, CR90, 0xFF, 0x10}, /* LCD Power Sequence Control 5 */ - {VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */ - {VIACR, CR96, 0xFF, 0x03}, /* DVP0 ; DVP0 Clock Skew */ - {VIACR, CR97, 0xFF, 0x03}, /* DFP high ; DFPH Clock Skew */ - {VIACR, CR99, 0xFF, 0x03}, /* DFP low ; DFPL Clock Skew*/ - {VIACR, CR9B, 0xFF, 0x07} /* DVI on DVP1 ; DVP1 Clock Skew*/ -}; - -/* For VT3324: Common Setting for Video Mode */ -struct io_reg CX700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, -{VIASR, SR15, 0x02, 0x02}, -{VIASR, SR16, 0xBF, 0x08}, -{VIASR, SR17, 0xFF, 0x1F}, -{VIASR, SR18, 0xFF, 0x4E}, -{VIASR, SR1A, 0xFB, 0x08}, -{VIASR, SR1B, 0xFF, 0xF0}, -{VIASR, SR1E, 0xFF, 0x01}, -{VIASR, SR2A, 0xFF, 0x00}, -{VIASR, SR2D, 0xFF, 0xFF}, /* VCK and LCK PLL power on. */ -{VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ -{VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ -{VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ -{VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ -{VIACR, CR32, 0xFF, 0x00}, -{VIACR, CR33, 0xFF, 0x00}, -{VIACR, CR35, 0xFF, 0x00}, -{VIACR, CR36, 0x08, 0x00}, -{VIACR, CR47, 0xC8, 0x00}, /* Clear VCK Plus. */ -{VIACR, CR69, 0xFF, 0x00}, -{VIACR, CR6A, 0xFF, 0x40}, -{VIACR, CR6B, 0xFF, 0x00}, -{VIACR, CR6C, 0xFF, 0x00}, -{VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ -{VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ -{VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ -{VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ -{VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ -{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ -{VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ -{VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ -{VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ -{VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ -{VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ -{VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ -{VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ -{VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ -{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ -{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ -{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ -{VIACR, CRD4, 0xFF, 0x81}, /* Second power sequence control */ -{VIACR, CR8B, 0xFF, 0x5D}, /* LCD Power Sequence Control 0 */ -{VIACR, CR8C, 0xFF, 0x2B}, /* LCD Power Sequence Control 1 */ -{VIACR, CR8D, 0xFF, 0x6F}, /* LCD Power Sequence Control 2 */ -{VIACR, CR8E, 0xFF, 0x2B}, /* LCD Power Sequence Control 3 */ -{VIACR, CR8F, 0xFF, 0x01}, /* LCD Power Sequence Control 4 */ -{VIACR, CR90, 0xFF, 0x01}, /* LCD Power Sequence Control 5 */ -{VIACR, CR91, 0xFF, 0x80}, /* 24/12 bit LVDS Data off */ -{VIACR, CR96, 0xFF, 0x00}, -{VIACR, CR97, 0xFF, 0x00}, -{VIACR, CR99, 0xFF, 0x00}, -{VIACR, CR9B, 0xFF, 0x00} -}; - -struct io_reg VX855_ModeXregs[] = { -{VIASR, SR10, 0xFF, 0x01}, -{VIASR, SR15, 0x02, 0x02}, -{VIASR, SR16, 0xBF, 0x08}, -{VIASR, SR17, 0xFF, 0x1F}, -{VIASR, SR18, 0xFF, 0x4E}, -{VIASR, SR1A, 0xFB, 0x08}, -{VIASR, SR1B, 0xFF, 0xF0}, -{VIASR, SR1E, 0x07, 0x01}, -{VIASR, SR2A, 0xF0, 0x00}, -{VIASR, SR58, 0xFF, 0x00}, -{VIASR, SR59, 0xFF, 0x00}, -{VIASR, SR2D, 0xFF, 0xFF}, /* VCK and LCK PLL power on. */ -{VIACR, CR09, 0xFF, 0x00}, /* Initial CR09=0*/ -{VIACR, CR11, 0x8F, 0x00}, /* IGA1 initial Vertical end */ -{VIACR, CR17, 0x7F, 0x00}, /* IGA1 CRT Mode control init */ -{VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ -{VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ -{VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ -{VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ -{VIACR, CR32, 0xFF, 0x00}, -{VIACR, CR33, 0x7F, 0x00}, -{VIACR, CR35, 0xFF, 0x00}, -{VIACR, CR36, 0x08, 0x00}, -{VIACR, CR69, 0xFF, 0x00}, -{VIACR, CR6A, 0xFD, 0x60}, -{VIACR, CR6B, 0xFF, 0x00}, -{VIACR, CR6C, 0xFF, 0x00}, -{VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ -{VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ -{VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ -{VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ -{VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ -{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ -{VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ -{VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ -{VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ -{VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ -{VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ -{VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ -{VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ -{VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ -{VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ -{VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ -{VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ -{VIACR, CRD4, 0xFF, 0x81}, /* Second power sequence control */ -{VIACR, CR91, 0xFF, 0x80}, /* 24/12 bit LVDS Data off */ -{VIACR, CR96, 0xFF, 0x00}, -{VIACR, CR97, 0xFF, 0x00}, -{VIACR, CR99, 0xFF, 0x00}, -{VIACR, CR9B, 0xFF, 0x00}, -{VIACR, CRD2, 0xFF, 0xFF} /* TMDS/LVDS control register. */ -}; - -/* Video Mode Table */ -/* Common Setting for Video Mode */ -struct io_reg CLE266_ModeXregs[] = { {VIASR, SR1E, 0xF0, 0x00}, -{VIASR, SR2A, 0x0F, 0x00}, -{VIASR, SR15, 0x02, 0x02}, -{VIASR, SR16, 0xBF, 0x08}, -{VIASR, SR17, 0xFF, 0x1F}, -{VIASR, SR18, 0xFF, 0x4E}, -{VIASR, SR1A, 0xFB, 0x08}, - -{VIACR, CR32, 0xFF, 0x00}, -{VIACR, CR35, 0xFF, 0x00}, -{VIACR, CR36, 0x08, 0x00}, -{VIACR, CR6A, 0xFF, 0x80}, -{VIACR, CR6A, 0xFF, 0xC0}, - -{VIACR, CR55, 0x80, 0x00}, -{VIACR, CR5D, 0x80, 0x00}, - -{VIAGR, GR20, 0xFF, 0x00}, -{VIAGR, GR21, 0xFF, 0x00}, -{VIAGR, GR22, 0xFF, 0x00}, - /* LCD Parameters */ -{VIACR, CR7A, 0xFF, 0x01}, /* LCD Parameter 1 */ -{VIACR, CR7B, 0xFF, 0x02}, /* LCD Parameter 2 */ -{VIACR, CR7C, 0xFF, 0x03}, /* LCD Parameter 3 */ -{VIACR, CR7D, 0xFF, 0x04}, /* LCD Parameter 4 */ -{VIACR, CR7E, 0xFF, 0x07}, /* LCD Parameter 5 */ -{VIACR, CR7F, 0xFF, 0x0A}, /* LCD Parameter 6 */ -{VIACR, CR80, 0xFF, 0x0D}, /* LCD Parameter 7 */ -{VIACR, CR81, 0xFF, 0x13}, /* LCD Parameter 8 */ -{VIACR, CR82, 0xFF, 0x16}, /* LCD Parameter 9 */ -{VIACR, CR83, 0xFF, 0x19}, /* LCD Parameter 10 */ -{VIACR, CR84, 0xFF, 0x1C}, /* LCD Parameter 11 */ -{VIACR, CR85, 0xFF, 0x1D}, /* LCD Parameter 12 */ -{VIACR, CR86, 0xFF, 0x1E}, /* LCD Parameter 13 */ -{VIACR, CR87, 0xFF, 0x1F}, /* LCD Parameter 14 */ - -}; - -/* Mode:1024X768 */ -struct io_reg PM1024x768[] = { {VIASR, 0x16, 0xBF, 0x0C}, -{VIASR, 0x18, 0xFF, 0x4C} -}; - -struct patch_table res_patch_table[] = { - {ARRAY_SIZE(PM1024x768), PM1024x768} -}; - -/* struct VPITTable { - unsigned char Misc; - unsigned char SR[StdSR]; - unsigned char CR[StdCR]; - unsigned char GR[StdGR]; - unsigned char AR[StdAR]; - };*/ - -struct VPITTable VPIT = { - /* Msic */ - 0xC7, - /* Sequencer */ - {0x01, 0x0F, 0x00, 0x0E}, - /* Graphic Controller */ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF}, - /* Attribute Controller */ - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x01, 0x00, 0x0F, 0x00} -}; - -/********************/ -/* Mode Table */ -/********************/ - -/* 480x640 */ -struct crt_mode_table CRTM480x640[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_25_175M, M480X640_R60_HSP, M480X640_R60_VSP, - {624, 480, 480, 144, 504, 48, 663, 640, 640, 23, 641, 3} } /* GTF*/ -}; - -/* 640x480*/ -struct crt_mode_table CRTM640x480[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_25_175M, M640X480_R60_HSP, M640X480_R60_VSP, - {800, 640, 648, 144, 656, 96, 525, 480, 480, 45, 490, 2} }, - {REFRESH_75, CLK_31_500M, M640X480_R75_HSP, M640X480_R75_VSP, - {840, 640, 640, 200, 656, 64, 500, 480, 480, 20, 481, 3} }, - {REFRESH_85, CLK_36_000M, M640X480_R85_HSP, M640X480_R85_VSP, - {832, 640, 640, 192, 696, 56, 509, 480, 480, 29, 481, 3} }, - {REFRESH_100, CLK_43_163M, M640X480_R100_HSP, M640X480_R100_VSP, - {848, 640, 640, 208, 680, 64, 509, 480, 480, 29, 481, 3} }, /*GTF*/ - {REFRESH_120, CLK_52_406M, M640X480_R120_HSP, - M640X480_R120_VSP, - {848, 640, 640, 208, 680, 64, 515, 480, 480, 35, 481, - 3} } /*GTF*/ -}; - -/*720x480 (GTF)*/ -struct crt_mode_table CRTM720x480[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_26_880M, M720X480_R60_HSP, M720X480_R60_VSP, - {896, 720, 720, 176, 736, 72, 497, 480, 480, 17, 481, 3} } - -}; - -/*720x576 (GTF)*/ -struct crt_mode_table CRTM720x576[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_32_668M, M720X576_R60_HSP, M720X576_R60_VSP, - {912, 720, 720, 192, 744, 72, 597, 576, 576, 21, 577, 3} } -}; - -/* 800x480 (CVT) */ -struct crt_mode_table CRTM800x480[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_29_581M, M800X480_R60_HSP, M800X480_R60_VSP, - {992, 800, 800, 192, 824, 72, 500, 480, 480, 20, 483, 7} } -}; - -/* 800x600*/ -struct crt_mode_table CRTM800x600[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_40_000M, M800X600_R60_HSP, M800X600_R60_VSP, - {1056, 800, 800, 256, 840, 128, 628, 600, 600, 28, 601, 4} }, - {REFRESH_75, CLK_49_500M, M800X600_R75_HSP, M800X600_R75_VSP, - {1056, 800, 800, 256, 816, 80, 625, 600, 600, 25, 601, 3} }, - {REFRESH_85, CLK_56_250M, M800X600_R85_HSP, M800X600_R85_VSP, - {1048, 800, 800, 248, 832, 64, 631, 600, 600, 31, 601, 3} }, - {REFRESH_100, CLK_68_179M, M800X600_R100_HSP, M800X600_R100_VSP, - {1072, 800, 800, 272, 848, 88, 636, 600, 600, 36, 601, 3} }, - {REFRESH_120, CLK_83_950M, M800X600_R120_HSP, - M800X600_R120_VSP, - {1088, 800, 800, 288, 856, 88, 643, 600, 600, 43, 601, - 3} } -}; - -/* 848x480 (CVT) */ -struct crt_mode_table CRTM848x480[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_31_500M, M848X480_R60_HSP, M848X480_R60_VSP, - {1056, 848, 848, 208, 872, 80, 500, 480, 480, 20, 483, 5} } -}; - -/*856x480 (GTF) convert to 852x480*/ -struct crt_mode_table CRTM852x480[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_31_728M, M852X480_R60_HSP, M852X480_R60_VSP, - {1064, 856, 856, 208, 872, 88, 497, 480, 480, 17, 481, 3} } -}; - -/*1024x512 (GTF)*/ -struct crt_mode_table CRTM1024x512[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_41_291M, M1024X512_R60_HSP, M1024X512_R60_VSP, - {1296, 1024, 1024, 272, 1056, 104, 531, 512, 512, 19, 513, 3} } - -}; - -/* 1024x600*/ -struct crt_mode_table CRTM1024x600[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_48_875M, M1024X600_R60_HSP, M1024X600_R60_VSP, - {1312, 1024, 1024, 288, 1064, 104, 622, 600, 600, 22, 601, 3} }, -}; - -/* 1024x768*/ -struct crt_mode_table CRTM1024x768[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_65_000M, M1024X768_R60_HSP, M1024X768_R60_VSP, - {1344, 1024, 1024, 320, 1048, 136, 806, 768, 768, 38, 771, 6} }, - {REFRESH_75, CLK_78_750M, M1024X768_R75_HSP, M1024X768_R75_VSP, - {1312, 1024, 1024, 288, 1040, 96, 800, 768, 768, 32, 769, 3} }, - {REFRESH_85, CLK_94_500M, M1024X768_R85_HSP, M1024X768_R85_VSP, - {1376, 1024, 1024, 352, 1072, 96, 808, 768, 768, 40, 769, 3} }, - {REFRESH_100, CLK_113_309M, M1024X768_R100_HSP, M1024X768_R100_VSP, - {1392, 1024, 1024, 368, 1096, 112, 814, 768, 768, 46, 769, 3} } -}; - -/* 1152x864*/ -struct crt_mode_table CRTM1152x864[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_75, CLK_108_000M, M1152X864_R75_HSP, M1152X864_R75_VSP, - {1600, 1152, 1152, 448, 1216, 128, 900, 864, 864, 36, 865, 3} } - -}; - -/* 1280x720 (HDMI 720P)*/ -struct crt_mode_table CRTM1280x720[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_74_481M, M1280X720_R60_HSP, M1280X720_R60_VSP, - {1648, 1280, 1280, 368, 1392, 40, 750, 720, 720, 30, 725, 5} }, - {REFRESH_50, CLK_60_466M, M1280X720_R50_HSP, M1280X720_R50_VSP, - {1632, 1280, 1280, 352, 1328, 128, 741, 720, 720, 21, 721, 3} } -}; - -/*1280x768 (GTF)*/ -struct crt_mode_table CRTM1280x768[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_80_136M, M1280X768_R60_HSP, M1280X768_R60_VSP, - {1680, 1280, 1280, 400, 1344, 136, 795, 768, 768, 27, 769, 3} }, - {REFRESH_50, CLK_65_178M, M1280X768_R50_HSP, M1280X768_R50_VSP, - {1648, 1280, 1280, 368, 1336, 128, 791, 768, 768, 23, 769, 3} } -}; - -/* 1280x800 (CVT) */ -struct crt_mode_table CRTM1280x800[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_83_375M, M1280X800_R60_HSP, M1280X800_R60_VSP, - {1680, 1280, 1280, 400, 1352, 128, 831, 800, 800, 31, 803, 6} } -}; - -/*1280x960*/ -struct crt_mode_table CRTM1280x960[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_108_000M, M1280X960_R60_HSP, M1280X960_R60_VSP, - {1800, 1280, 1280, 520, 1376, 112, 1000, 960, 960, 40, 961, 3} } -}; - -/* 1280x1024*/ -struct crt_mode_table CRTM1280x1024[] = { - /*r_rate,vclk,,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_108_000M, M1280X1024_R60_HSP, M1280X1024_R60_VSP, - {1688, 1280, 1280, 408, 1328, 112, 1066, 1024, 1024, 42, 1025, - 3} }, - {REFRESH_75, CLK_135_000M, M1280X1024_R75_HSP, M1280X1024_R75_VSP, - {1688, 1280, 1280, 408, 1296, 144, 1066, 1024, 1024, 42, 1025, - 3} }, - {REFRESH_85, CLK_157_500M, M1280X1024_R85_HSP, M1280X1024_R85_VSP, - {1728, 1280, 1280, 448, 1344, 160, 1072, 1024, 1024, 48, 1025, 3} } -}; - -/* 1368x768 (GTF) */ -struct crt_mode_table CRTM1368x768[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_85_860M, M1368X768_R60_HSP, M1368X768_R60_VSP, - {1800, 1368, 1368, 432, 1440, 144, 795, 768, 768, 27, 769, 3} } -}; - -/*1440x1050 (GTF)*/ -struct crt_mode_table CRTM1440x1050[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_125_104M, M1440X1050_R60_HSP, M1440X1050_R60_VSP, - {1936, 1440, 1440, 496, 1536, 152, 1077, 1040, 1040, 37, 1041, 3} } -}; - -/* 1600x1200*/ -struct crt_mode_table CRTM1600x1200[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_162_000M, M1600X1200_R60_HSP, M1600X1200_R60_VSP, - {2160, 1600, 1600, 560, 1664, 192, 1250, 1200, 1200, 50, 1201, - 3} }, - {REFRESH_75, CLK_202_500M, M1600X1200_R75_HSP, M1600X1200_R75_VSP, - {2160, 1600, 1600, 560, 1664, 192, 1250, 1200, 1200, 50, 1201, 3} } - -}; - -/* 1680x1050 (CVT) */ -struct crt_mode_table CRTM1680x1050[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_146_760M, M1680x1050_R60_HSP, M1680x1050_R60_VSP, - {2240, 1680, 1680, 560, 1784, 176, 1089, 1050, 1050, 39, 1053, - 6} }, - {REFRESH_75, CLK_187_000M, M1680x1050_R75_HSP, M1680x1050_R75_VSP, - {2272, 1680, 1680, 592, 1800, 176, 1099, 1050, 1050, 49, 1053, 6} } -}; - -/* 1680x1050 (CVT Reduce Blanking) */ -struct crt_mode_table CRTM1680x1050_RB[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_119_000M, M1680x1050_RB_R60_HSP, - M1680x1050_RB_R60_VSP, - {1840, 1680, 1680, 160, 1728, 32, 1080, 1050, 1050, 30, 1053, 6} } -}; - -/* 1920x1080 (CVT)*/ -struct crt_mode_table CRTM1920x1080[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_172_798M, M1920X1080_R60_HSP, M1920X1080_R60_VSP, - {2576, 1920, 1920, 656, 2048, 200, 1120, 1080, 1080, 40, 1083, 5} } -}; - -/* 1920x1080 (CVT with Reduce Blanking) */ -struct crt_mode_table CRTM1920x1080_RB[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_138_400M, M1920X1080_RB_R60_HSP, - M1920X1080_RB_R60_VSP, - {2080, 1920, 1920, 160, 1968, 32, 1111, 1080, 1080, 31, 1083, 5} } -}; - -/* 1920x1440*/ -struct crt_mode_table CRTM1920x1440[] = { - /*r_rate,vclk,hsp,vsp */ - /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_234_000M, M1920X1440_R60_HSP, M1920X1440_R60_VSP, - {2600, 1920, 1920, 680, 2048, 208, 1500, 1440, 1440, 60, 1441, - 3} }, - {REFRESH_75, CLK_297_500M, M1920X1440_R75_HSP, M1920X1440_R75_VSP, - {2640, 1920, 1920, 720, 2064, 224, 1500, 1440, 1440, 60, 1441, 3} } -}; - -/* 1400x1050 (CVT) */ -struct crt_mode_table CRTM1400x1050[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_121_750M, M1400X1050_R60_HSP, M1400X1050_R60_VSP, - {1864, 1400, 1400, 464, 1488, 144, 1089, 1050, 1050, 39, 1053, - 4} }, - {REFRESH_75, CLK_156_000M, M1400X1050_R75_HSP, M1400X1050_R75_VSP, - {1896, 1400, 1400, 496, 1504, 144, 1099, 1050, 1050, 49, 1053, 4} } -}; - -/* 1400x1050 (CVT Reduce Blanking) */ -struct crt_mode_table CRTM1400x1050_RB[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_101_000M, M1400X1050_RB_R60_HSP, - M1400X1050_RB_R60_VSP, - {1560, 1400, 1400, 160, 1448, 32, 1080, 1050, 1050, 30, 1053, 4} } -}; - -/* 960x600 (CVT) */ -struct crt_mode_table CRTM960x600[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_45_250M, M960X600_R60_HSP, M960X600_R60_VSP, - {1216, 960, 960, 256, 992, 96, 624, 600, 600, 24, 603, 6} } -}; - -/* 1000x600 (GTF) */ -struct crt_mode_table CRTM1000x600[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_48_000M, M1000X600_R60_HSP, M1000X600_R60_VSP, - {1288, 1000, 1000, 288, 1040, 104, 622, 600, 600, 22, 601, 3} } -}; - -/* 1024x576 (GTF) */ -struct crt_mode_table CRTM1024x576[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_46_996M, M1024X576_R60_HSP, M1024X576_R60_VSP, - {1312, 1024, 1024, 288, 1064, 104, 597, 576, 576, 21, 577, 3} } -}; - -/* 1088x612 (CVT) */ -struct crt_mode_table CRTM1088x612[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_52_977M, M1088X612_R60_HSP, M1088X612_R60_VSP, - {1392, 1088, 1088, 304, 1136, 104, 636, 612, 612, 24, 615, 5} } -}; - -/* 1152x720 (CVT) */ -struct crt_mode_table CRTM1152x720[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_66_750M, M1152X720_R60_HSP, M1152X720_R60_VSP, - {1488, 1152, 1152, 336, 1208, 112, 748, 720, 720, 28, 723, 6} } -}; - -/* 1200x720 (GTF) */ -struct crt_mode_table CRTM1200x720[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_70_159M, M1200X720_R60_HSP, M1200X720_R60_VSP, - {1568, 1200, 1200, 368, 1256, 128, 746, 720, 720, 26, 721, 3} } -}; - -/* 1200x900 (DCON) */ -struct crt_mode_table DCON1200x900[] = { - /* r_rate, vclk, hsp, vsp */ - {REFRESH_60, CLK_57_275M, M1200X900_R60_HSP, M1200X900_R60_VSP, - /* The correct htotal is 1240, but this doesn't raster on VX855. */ - /* Via suggested changing to a multiple of 16, hence 1264. */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {1264, 1200, 1200, 64, 1211, 32, 912, 900, 900, 12, 901, 10} } -}; - -/* 1280x600 (GTF) */ -struct crt_mode_table CRTM1280x600[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_61_500M, M1280x600_R60_HSP, M1280x600_R60_VSP, - {1648, 1280, 1280, 368, 1336, 128, 622, 600, 600, 22, 601, 3} } -}; - -/* 1360x768 (CVT) */ -struct crt_mode_table CRTM1360x768[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_84_750M, M1360X768_R60_HSP, M1360X768_R60_VSP, - {1776, 1360, 1360, 416, 1432, 136, 798, 768, 768, 30, 771, 5} } -}; - -/* 1360x768 (CVT Reduce Blanking) */ -struct crt_mode_table CRTM1360x768_RB[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_72_000M, M1360X768_RB_R60_HSP, - M1360X768_RB_R60_VSP, - {1520, 1360, 1360, 160, 1408, 32, 790, 768, 768, 22, 771, 5} } -}; - -/* 1366x768 (GTF) */ -struct crt_mode_table CRTM1366x768[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_85_860M, M1368X768_R60_HSP, M1368X768_R60_VSP, - {1800, 1368, 1368, 432, 1440, 144, 795, 768, 768, 27, 769, 3} }, - {REFRESH_50, CLK_69_924M, M1368X768_R50_HSP, M1368X768_R50_VSP, - {1768, 1368, 1368, 400, 1424, 144, 791, 768, 768, 23, 769, 3} } -}; - -/* 1440x900 (CVT) */ -struct crt_mode_table CRTM1440x900[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_106_500M, M1440X900_R60_HSP, M1440X900_R60_VSP, - {1904, 1440, 1440, 464, 1520, 152, 934, 900, 900, 34, 903, 6} }, - {REFRESH_75, CLK_136_700M, M1440X900_R75_HSP, M1440X900_R75_VSP, - {1936, 1440, 1440, 496, 1536, 152, 942, 900, 900, 42, 903, 6} } -}; - -/* 1440x900 (CVT Reduce Blanking) */ -struct crt_mode_table CRTM1440x900_RB[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_88_750M, M1440X900_RB_R60_HSP, - M1440X900_RB_R60_VSP, - {1600, 1440, 1440, 160, 1488, 32, 926, 900, 900, 26, 903, 6} } -}; - -/* 1600x900 (CVT) */ -struct crt_mode_table CRTM1600x900[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_118_840M, M1600X900_R60_HSP, M1600X900_R60_VSP, - {2112, 1600, 1600, 512, 1688, 168, 934, 900, 900, 34, 903, 5} } -}; - -/* 1600x900 (CVT Reduce Blanking) */ -struct crt_mode_table CRTM1600x900_RB[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_97_750M, M1600X900_RB_R60_HSP, - M1600X900_RB_R60_VSP, - {1760, 1600, 1600, 160, 1648, 32, 926, 900, 900, 26, 903, 5} } -}; - -/* 1600x1024 (GTF) */ -struct crt_mode_table CRTM1600x1024[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_136_700M, M1600X1024_R60_HSP, M1600X1024_R60_VSP, - {2144, 1600, 1600, 544, 1704, 168, 1060, 1024, 1024, 36, 1025, 3} } -}; - -/* 1792x1344 (DMT) */ -struct crt_mode_table CRTM1792x1344[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_204_000M, M1792x1344_R60_HSP, M1792x1344_R60_VSP, - {2448, 1792, 1792, 656, 1920, 200, 1394, 1344, 1344, 50, 1345, 3} } -}; - -/* 1856x1392 (DMT) */ -struct crt_mode_table CRTM1856x1392[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_218_500M, M1856x1392_R60_HSP, M1856x1392_R60_VSP, - {2528, 1856, 1856, 672, 1952, 224, 1439, 1392, 1392, 47, 1393, 3} } -}; - -/* 1920x1200 (CVT) */ -struct crt_mode_table CRTM1920x1200[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_193_295M, M1920X1200_R60_HSP, M1920X1200_R60_VSP, - {2592, 1920, 1920, 672, 2056, 200, 1245, 1200, 1200, 45, 1203, 6} } -}; - -/* 1920x1200 (CVT with Reduce Blanking) */ -struct crt_mode_table CRTM1920x1200_RB[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_153_920M, M1920X1200_RB_R60_HSP, - M1920X1200_RB_R60_VSP, - {2080, 1920, 1920, 160, 1968, 32, 1235, 1200, 1200, 35, 1203, 6} } -}; - -/* 2048x1536 (CVT) */ -struct crt_mode_table CRTM2048x1536[] = { - /* r_rate, vclk, hsp, vsp */ - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {REFRESH_60, CLK_267_250M, M2048x1536_R60_HSP, M2048x1536_R60_VSP, - {2800, 2048, 2048, 752, 2200, 224, 1592, 1536, 1536, 56, 1539, 4} } -}; - -struct VideoModeTable viafb_modes[] = { - /* Display : 480x640 (GTF) */ - {CRTM480x640, ARRAY_SIZE(CRTM480x640)}, - - /* Display : 640x480 */ - {CRTM640x480, ARRAY_SIZE(CRTM640x480)}, - - /* Display : 720x480 (GTF) */ - {CRTM720x480, ARRAY_SIZE(CRTM720x480)}, - - /* Display : 720x576 (GTF) */ - {CRTM720x576, ARRAY_SIZE(CRTM720x576)}, - - /* Display : 800x600 */ - {CRTM800x600, ARRAY_SIZE(CRTM800x600)}, - - /* Display : 800x480 (CVT) */ - {CRTM800x480, ARRAY_SIZE(CRTM800x480)}, - - /* Display : 848x480 (CVT) */ - {CRTM848x480, ARRAY_SIZE(CRTM848x480)}, - - /* Display : 852x480 (GTF) */ - {CRTM852x480, ARRAY_SIZE(CRTM852x480)}, - - /* Display : 1024x512 (GTF) */ - {CRTM1024x512, ARRAY_SIZE(CRTM1024x512)}, - - /* Display : 1024x600 */ - {CRTM1024x600, ARRAY_SIZE(CRTM1024x600)}, - - /* Display : 1024x768 */ - {CRTM1024x768, ARRAY_SIZE(CRTM1024x768)}, - - /* Display : 1152x864 */ - {CRTM1152x864, ARRAY_SIZE(CRTM1152x864)}, - - /* Display : 1280x768 (GTF) */ - {CRTM1280x768, ARRAY_SIZE(CRTM1280x768)}, - - /* Display : 960x600 (CVT) */ - {CRTM960x600, ARRAY_SIZE(CRTM960x600)}, - - /* Display : 1000x600 (GTF) */ - {CRTM1000x600, ARRAY_SIZE(CRTM1000x600)}, - - /* Display : 1024x576 (GTF) */ - {CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, - - /* Display : 1088x612 (GTF) */ - {CRTM1088x612, ARRAY_SIZE(CRTM1088x612)}, - - /* Display : 1152x720 (CVT) */ - {CRTM1152x720, ARRAY_SIZE(CRTM1152x720)}, - - /* Display : 1200x720 (GTF) */ - {CRTM1200x720, ARRAY_SIZE(CRTM1200x720)}, - - /* Display : 1200x900 (DCON) */ - {DCON1200x900, ARRAY_SIZE(DCON1200x900)}, - - /* Display : 1280x600 (GTF) */ - {CRTM1280x600, ARRAY_SIZE(CRTM1280x600)}, - - /* Display : 1280x800 (CVT) */ - {CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, - - /* Display : 1280x960 */ - {CRTM1280x960, ARRAY_SIZE(CRTM1280x960)}, - - /* Display : 1280x1024 */ - {CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)}, - - /* Display : 1360x768 (CVT) */ - {CRTM1360x768, ARRAY_SIZE(CRTM1360x768)}, - - /* Display : 1366x768 */ - {CRTM1366x768, ARRAY_SIZE(CRTM1366x768)}, - - /* Display : 1368x768 (GTF) */ - {CRTM1368x768, ARRAY_SIZE(CRTM1368x768)}, - - /* Display : 1440x900 (CVT) */ - {CRTM1440x900, ARRAY_SIZE(CRTM1440x900)}, - - /* Display : 1440x1050 (GTF) */ - {CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)}, - - /* Display : 1600x900 (CVT) */ - {CRTM1600x900, ARRAY_SIZE(CRTM1600x900)}, - - /* Display : 1600x1024 (GTF) */ - {CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)}, - - /* Display : 1600x1200 */ - {CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)}, - - /* Display : 1680x1050 (CVT) */ - {CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)}, - - /* Display : 1792x1344 (DMT) */ - {CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)}, - - /* Display : 1856x1392 (DMT) */ - {CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)}, - - /* Display : 1920x1440 */ - {CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)}, - - /* Display : 2048x1536 */ - {CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)}, - - /* Display : 1280x720 */ - {CRTM1280x720, ARRAY_SIZE(CRTM1280x720)}, - - /* Display : 1920x1080 (CVT) */ - {CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)}, - - /* Display : 1920x1200 (CVT) */ - {CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)}, - - /* Display : 1400x1050 (CVT) */ - {CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)} -}; - -struct VideoModeTable viafb_rb_modes[] = { - /* Display : 1360x768 (CVT Reduce Blanking) */ - {CRTM1360x768_RB, ARRAY_SIZE(CRTM1360x768_RB)}, - - /* Display : 1440x900 (CVT Reduce Blanking) */ - {CRTM1440x900_RB, ARRAY_SIZE(CRTM1440x900_RB)}, - - /* Display : 1400x1050 (CVT Reduce Blanking) */ - {CRTM1400x1050_RB, ARRAY_SIZE(CRTM1400x1050_RB)}, - - /* Display : 1600x900 (CVT Reduce Blanking) */ - {CRTM1600x900_RB, ARRAY_SIZE(CRTM1600x900_RB)}, - - /* Display : 1680x1050 (CVT Reduce Blanking) */ - {CRTM1680x1050_RB, ARRAY_SIZE(CRTM1680x1050_RB)}, - - /* Display : 1920x1080 (CVT Reduce Blanking) */ - {CRTM1920x1080_RB, ARRAY_SIZE(CRTM1920x1080_RB)}, - - /* Display : 1920x1200 (CVT Reduce Blanking) */ - {CRTM1920x1200_RB, ARRAY_SIZE(CRTM1920x1200_RB)} -}; - -struct crt_mode_table CEAM1280x720[] = { - {REFRESH_60, CLK_74_270M, M1280X720_CEA_R60_HSP, - M1280X720_CEA_R60_VSP, - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {1650, 1280, 1280, 370, 1390, 40, 750, 720, 720, 30, 725, 5} } -}; -struct crt_mode_table CEAM1920x1080[] = { - {REFRESH_60, CLK_148_500M, M1920X1080_CEA_R60_HSP, - M1920X1080_CEA_R60_VSP, - /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ - {2200, 1920, 1920, 300, 2008, 44, 1125, 1080, 1080, 45, 1084, 5} } -}; -struct VideoModeTable CEA_HDMI_Modes[] = { - /* Display : 1280x720 */ - {CEAM1280x720, ARRAY_SIZE(CEAM1280x720)}, - {CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)} -}; - -int NUM_TOTAL_RES_MAP_REFRESH = ARRAY_SIZE(res_map_refresh_tbl); -int NUM_TOTAL_CEA_MODES = ARRAY_SIZE(CEA_HDMI_Modes); -int NUM_TOTAL_CN400_ModeXregs = ARRAY_SIZE(CN400_ModeXregs); -int NUM_TOTAL_CN700_ModeXregs = ARRAY_SIZE(CN700_ModeXregs); -int NUM_TOTAL_KM400_ModeXregs = ARRAY_SIZE(KM400_ModeXregs); -int NUM_TOTAL_CX700_ModeXregs = ARRAY_SIZE(CX700_ModeXregs); -int NUM_TOTAL_VX855_ModeXregs = ARRAY_SIZE(VX855_ModeXregs); -int NUM_TOTAL_CLE266_ModeXregs = ARRAY_SIZE(CLE266_ModeXregs); -int NUM_TOTAL_PATCH_MODE = ARRAY_SIZE(res_patch_table); - - -struct VideoModeTable *viafb_get_mode(int hres, int vres) -{ - u32 i; - for (i = 0; i < ARRAY_SIZE(viafb_modes); i++) - if (viafb_modes[i].mode_array && - viafb_modes[i].crtc[0].crtc.hor_addr == hres && - viafb_modes[i].crtc[0].crtc.ver_addr == vres) - return &viafb_modes[i]; - - return NULL; -} - -struct VideoModeTable *viafb_get_rb_mode(int hres, int vres) -{ - u32 i; - for (i = 0; i < ARRAY_SIZE(viafb_rb_modes); i++) - if (viafb_rb_modes[i].mode_array && - viafb_rb_modes[i].crtc[0].crtc.hor_addr == hres && - viafb_rb_modes[i].crtc[0].crtc.ver_addr == vres) - return &viafb_rb_modes[i]; - - return NULL; -} diff --git a/drivers/video/via/viamode.h b/drivers/video/via/viamode.h deleted file mode 100644 index 5b1ced86514..00000000000 --- a/drivers/video/via/viamode.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 __VIAMODE_H__ -#define __VIAMODE_H__ - -#include "global.h" - -struct VPITTable { - unsigned char Misc; - unsigned char SR[StdSR]; - unsigned char GR[StdGR]; - unsigned char AR[StdAR]; -}; - -struct VideoModeTable { - struct crt_mode_table *crtc; - int mode_array; -}; - -struct patch_table { - int table_length; - struct io_reg *io_reg_table; -}; - -struct res_map_refresh { - int hres; - int vres; - int pixclock; - int vmode_refresh; -}; - -extern int NUM_TOTAL_RES_MAP_REFRESH; -extern int NUM_TOTAL_CEA_MODES; -extern int NUM_TOTAL_CN400_ModeXregs; -extern int NUM_TOTAL_CN700_ModeXregs; -extern int NUM_TOTAL_KM400_ModeXregs; -extern int NUM_TOTAL_CX700_ModeXregs; -extern int NUM_TOTAL_VX855_ModeXregs; -extern int NUM_TOTAL_CLE266_ModeXregs; -extern int NUM_TOTAL_PATCH_MODE; - -/********************/ -/* Mode Table */ -/********************/ - -extern struct crt_mode_table CEAM1280x720[]; -extern struct crt_mode_table CEAM1920x1080[]; -extern struct VideoModeTable CEA_HDMI_Modes[]; - -extern struct res_map_refresh res_map_refresh_tbl[]; -extern struct io_reg CN400_ModeXregs[]; -extern struct io_reg CN700_ModeXregs[]; -extern struct io_reg KM400_ModeXregs[]; -extern struct io_reg CX700_ModeXregs[]; -extern struct io_reg VX800_ModeXregs[]; -extern struct io_reg VX855_ModeXregs[]; -extern struct io_reg CLE266_ModeXregs[]; -extern struct io_reg PM1024x768[]; -extern struct patch_table res_patch_table[]; -extern struct VPITTable VPIT; - -struct VideoModeTable *viafb_get_mode(int hres, int vres); -struct VideoModeTable *viafb_get_rb_mode(int hres, int vres); - -#endif /* __VIAMODE_H__ */ diff --git a/drivers/video/via/vt1636.c b/drivers/video/via/vt1636.c deleted file mode 100644 index 60e4192c2b3..00000000000 --- a/drivers/video/via/vt1636.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * 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 <linux/via-core.h> -#include <linux/via_i2c.h> -#include "global.h" - -static const struct IODATA common_init_data[] = { -/* Index, Mask, Value */ - /* Set panel power sequence timing */ - {0x10, 0xC0, 0x00}, - /* T1: VDD on - Data on. Each increment is 1 ms. (50ms = 031h) */ - {0x0B, 0xFF, 0x40}, - /* T2: Data on - Backlight on. Each increment is 2 ms. (210ms = 068h) */ - {0x0C, 0xFF, 0x31}, - /* T3: Backlight off -Data off. Each increment is 2 ms. (210ms = 068h)*/ - {0x0D, 0xFF, 0x31}, - /* T4: Data off - VDD off. Each increment is 1 ms. (50ms = 031h) */ - {0x0E, 0xFF, 0x68}, - /* T5: VDD off - VDD on. Each increment is 100 ms. (500ms = 04h) */ - {0x0F, 0xFF, 0x68}, - /* LVDS output power up */ - {0x09, 0xA0, 0xA0}, - /* turn on back light */ - {0x10, 0x33, 0x13} -}; - -/* Index, Mask, Value */ -static const struct IODATA dual_channel_enable_data = {0x08, 0xF0, 0xE0}; -static const struct IODATA single_channel_enable_data = {0x08, 0xF0, 0x00}; -static const struct IODATA dithering_enable_data = {0x0A, 0x70, 0x50}; -static const struct IODATA dithering_disable_data = {0x0A, 0x70, 0x00}; -static const struct IODATA vdd_on_data = {0x10, 0x20, 0x20}; -static const struct IODATA vdd_off_data = {0x10, 0x20, 0x00}; - -u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information - *plvds_setting_info, struct lvds_chip_information *plvds_chip_info, - u8 index) -{ - u8 data; - - viafb_i2c_readbyte(plvds_chip_info->i2c_port, - plvds_chip_info->lvds_chip_slave_addr, index, &data); - return data; -} - -void viafb_gpio_i2c_write_mask_lvds(struct lvds_setting_information - *plvds_setting_info, struct lvds_chip_information - *plvds_chip_info, struct IODATA io_data) -{ - int index, data; - - index = io_data.Index; - data = viafb_gpio_i2c_read_lvds(plvds_setting_info, plvds_chip_info, - index); - data = (data & (~io_data.Mask)) | io_data.Data; - - viafb_i2c_writebyte(plvds_chip_info->i2c_port, - plvds_chip_info->lvds_chip_slave_addr, index, data); -} - -void viafb_init_lvds_vt1636(struct lvds_setting_information - *plvds_setting_info, struct lvds_chip_information *plvds_chip_info) -{ - int reg_num, i; - - /* Common settings: */ - reg_num = ARRAY_SIZE(common_init_data); - for (i = 0; i < reg_num; i++) - viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, - plvds_chip_info, common_init_data[i]); - - /* Input Data Mode Select */ - if (plvds_setting_info->device_lcd_dualedge) - viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, - plvds_chip_info, dual_channel_enable_data); - else - viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, - plvds_chip_info, single_channel_enable_data); - - if (plvds_setting_info->LCDDithering) - viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, - plvds_chip_info, dithering_enable_data); - else - viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, - plvds_chip_info, dithering_disable_data); -} - -void viafb_enable_lvds_vt1636(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, plvds_chip_info, - vdd_on_data); -} - -void viafb_disable_lvds_vt1636(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, plvds_chip_info, - vdd_off_data); -} - -bool viafb_lvds_identify_vt1636(u8 i2c_adapter) -{ - u8 Buffer[2]; - - DEBUG_MSG(KERN_INFO "viafb_lvds_identify_vt1636.\n"); - - /* Sense VT1636 LVDS Transmiter */ - viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr = - VT1636_LVDS_I2C_ADDR; - - /* Check vendor ID first: */ - if (viafb_i2c_readbyte(i2c_adapter, VT1636_LVDS_I2C_ADDR, - 0x00, &Buffer[0])) - return false; - viafb_i2c_readbyte(i2c_adapter, VT1636_LVDS_I2C_ADDR, 0x01, &Buffer[1]); - - if (!((Buffer[0] == 0x06) && (Buffer[1] == 0x11))) - return false; - - /* Check Chip ID: */ - viafb_i2c_readbyte(i2c_adapter, VT1636_LVDS_I2C_ADDR, 0x02, &Buffer[0]); - viafb_i2c_readbyte(i2c_adapter, VT1636_LVDS_I2C_ADDR, 0x03, &Buffer[1]); - if ((Buffer[0] == 0x45) && (Buffer[1] == 0x33)) { - viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = - VT1636_LVDS; - return true; - } - - return false; -} - -static int get_clk_range_index(u32 Clk) -{ - if (Clk < DPA_CLK_30M) - return DPA_CLK_RANGE_30M; - else if (Clk < DPA_CLK_50M) - return DPA_CLK_RANGE_30_50M; - else if (Clk < DPA_CLK_70M) - return DPA_CLK_RANGE_50_70M; - else if (Clk < DPA_CLK_100M) - return DPA_CLK_RANGE_70_100M; - else if (Clk < DPA_CLK_150M) - return DPA_CLK_RANGE_100_150M; - else - return DPA_CLK_RANGE_150M; -} - -static int get_lvds_dpa_setting_index(int panel_size_id, - struct VT1636_DPA_SETTING *p_vt1636_dpasetting_tbl, - int tbl_size) -{ - int i; - - for (i = 0; i < tbl_size; i++) { - if (panel_size_id == p_vt1636_dpasetting_tbl->PanelSizeID) - return i; - - p_vt1636_dpasetting_tbl++; - } - - return 0; -} - -static void set_dpa_vt1636(struct lvds_setting_information - *plvds_setting_info, struct lvds_chip_information *plvds_chip_info, - struct VT1636_DPA_SETTING *p_vt1636_dpa_setting) -{ - struct IODATA io_data; - - io_data.Index = 0x09; - io_data.Mask = 0x1F; - io_data.Data = p_vt1636_dpa_setting->CLK_SEL_ST1; - viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, - plvds_chip_info, io_data); - - io_data.Index = 0x08; - io_data.Mask = 0x0F; - io_data.Data = p_vt1636_dpa_setting->CLK_SEL_ST2; - viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, plvds_chip_info, - io_data); -} - -void viafb_vt1636_patch_skew_on_vt3324( - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - int index, size; - - DEBUG_MSG(KERN_INFO "viafb_vt1636_patch_skew_on_vt3324.\n"); - - /* Graphics DPA settings: */ - index = get_clk_range_index(plvds_setting_info->vclk); - viafb_set_dpa_gfx(plvds_chip_info->output_interface, - &GFX_DPA_SETTING_TBL_VT3324[index]); - - /* LVDS Transmitter DPA settings: */ - size = ARRAY_SIZE(VT1636_DPA_SETTING_TBL_VT3324); - index = - get_lvds_dpa_setting_index(plvds_setting_info->lcd_panel_id, - VT1636_DPA_SETTING_TBL_VT3324, size); - set_dpa_vt1636(plvds_setting_info, plvds_chip_info, - &VT1636_DPA_SETTING_TBL_VT3324[index]); -} - -void viafb_vt1636_patch_skew_on_vt3327( - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - int index, size; - - DEBUG_MSG(KERN_INFO "viafb_vt1636_patch_skew_on_vt3327.\n"); - - /* Graphics DPA settings: */ - index = get_clk_range_index(plvds_setting_info->vclk); - viafb_set_dpa_gfx(plvds_chip_info->output_interface, - &GFX_DPA_SETTING_TBL_VT3327[index]); - - /* LVDS Transmitter DPA settings: */ - size = ARRAY_SIZE(VT1636_DPA_SETTING_TBL_VT3327); - index = - get_lvds_dpa_setting_index(plvds_setting_info->lcd_panel_id, - VT1636_DPA_SETTING_TBL_VT3327, size); - set_dpa_vt1636(plvds_setting_info, plvds_chip_info, - &VT1636_DPA_SETTING_TBL_VT3327[index]); -} - -void viafb_vt1636_patch_skew_on_vt3364( - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info) -{ - int index; - - DEBUG_MSG(KERN_INFO "viafb_vt1636_patch_skew_on_vt3364.\n"); - - /* Graphics DPA settings: */ - index = get_clk_range_index(plvds_setting_info->vclk); - viafb_set_dpa_gfx(plvds_chip_info->output_interface, - &GFX_DPA_SETTING_TBL_VT3364[index]); -} diff --git a/drivers/video/via/vt1636.h b/drivers/video/via/vt1636.h deleted file mode 100644 index 4c1314e5746..00000000000 --- a/drivers/video/via/vt1636.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 _VT1636_H_ -#define _VT1636_H_ -#include "chip.h" -bool viafb_lvds_identify_vt1636(u8 i2c_adapter); -void viafb_init_lvds_vt1636(struct lvds_setting_information - *plvds_setting_info, struct lvds_chip_information *plvds_chip_info); -void viafb_enable_lvds_vt1636(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -void viafb_disable_lvds_vt1636(struct lvds_setting_information - *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -void viafb_vt1636_patch_skew_on_vt3324( - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -void viafb_vt1636_patch_skew_on_vt3327( - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); -void viafb_vt1636_patch_skew_on_vt3364( - struct lvds_setting_information *plvds_setting_info, - struct lvds_chip_information *plvds_chip_info); - -#endif |
