aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/via/hw.c
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2010-04-22 15:48:09 -0400
committerJonathan Corbet <corbet@lwn.net>2010-05-07 19:16:02 -0400
commit24b4d82e4715841848a499534ed5cb7db3d6bca3 (patch)
tree957c3664ac41da616e2aec7e8adb07247ee1a551 /drivers/video/via/hw.c
parentf045f77bc0bf238a871b10bea9e425329a8e4abc (diff)
viafb: Separate global and fb-specific data
This patch moves data of interest into a new viafb_dev structure which describes the device as a whole; the idea here is to create a separation between what all devices may need and what the framebuffer device in particular needs. I've also made some small steps toward thinning out the global.h mess. Cc: ScottFang@viatech.com.cn Cc: JosephChan@via.com.tw Cc: Harald Welte <laforge@gnumonks.org> Acked-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'drivers/video/via/hw.c')
-rw-r--r--drivers/video/via/hw.c131
1 files changed, 6 insertions, 125 deletions
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index 2322612fbb95..f2425ae228ae 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -18,7 +18,7 @@
18 * Foundation, Inc., 18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */ 20 */
21 21#include "via-core.h"
22#include "global.h" 22#include "global.h"
23 23
24static struct pll_map pll_value[] = { 24static struct pll_map pll_value[] = {
@@ -526,8 +526,7 @@ static void dvi_patch_skew_dvp_low(void);
526static void set_dvi_output_path(int set_iga, int output_interface); 526static void set_dvi_output_path(int set_iga, int output_interface);
527static void set_lcd_output_path(int set_iga, int output_interface); 527static void set_lcd_output_path(int set_iga, int output_interface);
528static void load_fix_bit_crtc_reg(void); 528static void load_fix_bit_crtc_reg(void);
529static void init_gfx_chip_info(struct pci_dev *pdev, 529static void init_gfx_chip_info(int chip_type);
530 const struct pci_device_id *pdi);
531static void init_tmds_chip_info(void); 530static void init_tmds_chip_info(void);
532static void init_lvds_chip_info(void); 531static void init_lvds_chip_info(void);
533static void device_screen_off(void); 532static void device_screen_off(void);
@@ -1911,10 +1910,9 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
1911 1910
1912} 1911}
1913 1912
1914void viafb_init_chip_info(struct pci_dev *pdev, 1913void viafb_init_chip_info(int chip_type)
1915 const struct pci_device_id *pdi)
1916{ 1914{
1917 init_gfx_chip_info(pdev, pdi); 1915 init_gfx_chip_info(chip_type);
1918 init_tmds_chip_info(); 1916 init_tmds_chip_info();
1919 init_lvds_chip_info(); 1917 init_lvds_chip_info();
1920 1918
@@ -1981,12 +1979,11 @@ void viafb_update_device_setting(int hres, int vres,
1981 } 1979 }
1982} 1980}
1983 1981
1984static void init_gfx_chip_info(struct pci_dev *pdev, 1982static void init_gfx_chip_info(int chip_type)
1985 const struct pci_device_id *pdi)
1986{ 1983{
1987 u8 tmp; 1984 u8 tmp;
1988 1985
1989 viaparinfo->chip_info->gfx_chip_name = pdi->driver_data; 1986 viaparinfo->chip_info->gfx_chip_name = chip_type;
1990 1987
1991 /* Check revision of CLE266 Chip */ 1988 /* Check revision of CLE266 Chip */
1992 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { 1989 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
@@ -2489,122 +2486,6 @@ static void disable_second_display_channel(void)
2489 viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6); 2486 viafb_write_reg_mask(CR6A, VIACR, BIT6, BIT6);
2490} 2487}
2491 2488
2492static u_int16_t via_function3[] = {
2493 CLE266_FUNCTION3, KM400_FUNCTION3, CN400_FUNCTION3, CN700_FUNCTION3,
2494 CX700_FUNCTION3, KM800_FUNCTION3, KM890_FUNCTION3, P4M890_FUNCTION3,
2495 P4M900_FUNCTION3, VX800_FUNCTION3, VX855_FUNCTION3,
2496};
2497
2498/* Get the BIOS-configured framebuffer size from PCI configuration space
2499 * of function 3 in the respective chipset */
2500int viafb_get_fb_size_from_pci(void)
2501{
2502 int i;
2503 u_int8_t offset = 0;
2504 u_int32_t FBSize;
2505 u_int32_t VideoMemSize;
2506
2507 /* search for the "FUNCTION3" device in this chipset */
2508 for (i = 0; i < ARRAY_SIZE(via_function3); i++) {
2509 struct pci_dev *pdev;
2510
2511 pdev = pci_get_device(PCI_VENDOR_ID_VIA, via_function3[i],
2512 NULL);
2513 if (!pdev)
2514 continue;
2515
2516 DEBUG_MSG(KERN_INFO "Device ID = %x\n", pdev->device);
2517
2518 switch (pdev->device) {
2519 case CLE266_FUNCTION3:
2520 case KM400_FUNCTION3:
2521 offset = 0xE0;
2522 break;
2523 case CN400_FUNCTION3:
2524 case CN700_FUNCTION3:
2525 case CX700_FUNCTION3:
2526 case KM800_FUNCTION3:
2527 case KM890_FUNCTION3:
2528 case P4M890_FUNCTION3:
2529 case P4M900_FUNCTION3:
2530 case VX800_FUNCTION3:
2531 case VX855_FUNCTION3:
2532 /*case CN750_FUNCTION3: */
2533 offset = 0xA0;
2534 break;
2535 }
2536
2537 if (!offset)
2538 break;
2539
2540 pci_read_config_dword(pdev, offset, &FBSize);
2541 pci_dev_put(pdev);
2542 }
2543
2544 if (!offset) {
2545 printk(KERN_ERR "cannot determine framebuffer size\n");
2546 return -EIO;
2547 }
2548
2549 FBSize = FBSize & 0x00007000;
2550 DEBUG_MSG(KERN_INFO "FB Size = %x\n", FBSize);
2551
2552 if (viaparinfo->chip_info->gfx_chip_name < UNICHROME_CX700) {
2553 switch (FBSize) {
2554 case 0x00004000:
2555 VideoMemSize = (16 << 20); /*16M */
2556 break;
2557
2558 case 0x00005000:
2559 VideoMemSize = (32 << 20); /*32M */
2560 break;
2561
2562 case 0x00006000:
2563 VideoMemSize = (64 << 20); /*64M */
2564 break;
2565
2566 default:
2567 VideoMemSize = (32 << 20); /*32M */
2568 break;
2569 }
2570 } else {
2571 switch (FBSize) {
2572 case 0x00001000:
2573 VideoMemSize = (8 << 20); /*8M */
2574 break;
2575
2576 case 0x00002000:
2577 VideoMemSize = (16 << 20); /*16M */
2578 break;
2579
2580 case 0x00003000:
2581 VideoMemSize = (32 << 20); /*32M */
2582 break;
2583
2584 case 0x00004000:
2585 VideoMemSize = (64 << 20); /*64M */
2586 break;
2587
2588 case 0x00005000:
2589 VideoMemSize = (128 << 20); /*128M */
2590 break;
2591
2592 case 0x00006000:
2593 VideoMemSize = (256 << 20); /*256M */
2594 break;
2595
2596 case 0x00007000: /* Only on VX855/875 */
2597 VideoMemSize = (512 << 20); /*512M */
2598 break;
2599
2600 default:
2601 VideoMemSize = (32 << 20); /*32M */
2602 break;
2603 }
2604 }
2605
2606 return VideoMemSize;
2607}
2608 2489
2609void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ 2490void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
2610 *p_gfx_dpa_setting) 2491 *p_gfx_dpa_setting)