diff options
author | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2010-04-17 15:44:53 -0400 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2010-05-07 19:17:38 -0400 |
commit | 100e74a150d3a31d4c12658c926429ceb880d2f7 (patch) | |
tree | d2fe1094e53c320c7027438c70ee2b66f67eaeed /drivers/video/via | |
parent | 2749413db17723cf894036c0eaf339f289bcc841 (diff) |
viafb: move some modesetting functions to a seperate file
viafb: move some modesetting functions to a seperate file
This patch moves the modesetting functions which are already cleaned up
to a seperate file.
Just the beginning to bring some structure in this mess.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/via')
-rw-r--r-- | drivers/video/via/Makefile | 3 | ||||
-rw-r--r-- | drivers/video/via/hw.c | 96 | ||||
-rw-r--r-- | drivers/video/via/hw.h | 5 | ||||
-rw-r--r-- | drivers/video/via/via_modesetting.c | 126 | ||||
-rw-r--r-- | drivers/video/via/via_modesetting.h | 38 |
5 files changed, 166 insertions, 102 deletions
diff --git a/drivers/video/via/Makefile b/drivers/video/via/Makefile index 8c42a42c3dbb..d496adb0f832 100644 --- a/drivers/video/via/Makefile +++ b/drivers/video/via/Makefile | |||
@@ -6,5 +6,4 @@ obj-$(CONFIG_FB_VIA) += viafb.o | |||
6 | 6 | ||
7 | viafb-y :=viafbdev.o hw.o via_i2c.o dvi.o lcd.o ioctl.o accel.o \ | 7 | viafb-y :=viafbdev.o hw.o via_i2c.o dvi.o lcd.o ioctl.o accel.o \ |
8 | via_utility.o vt1636.o global.o tblDPASetting.o viamode.o tbl1636.o \ | 8 | via_utility.o vt1636.o global.o tblDPASetting.o viamode.o tbl1636.o \ |
9 | via-core.o via-gpio.o | 9 | via-core.o via-gpio.o via_modesetting.o |
10 | |||
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c index 1628a5f93dc2..d474fbee3350 100644 --- a/drivers/video/via/hw.c +++ b/drivers/video/via/hw.c | |||
@@ -624,102 +624,6 @@ void viafb_set_iga_path(void) | |||
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | void via_set_primary_address(u32 addr) | ||
628 | { | ||
629 | DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr); | ||
630 | via_write_reg(VIACR, 0x0D, addr & 0xFF); | ||
631 | via_write_reg(VIACR, 0x0C, (addr >> 8) & 0xFF); | ||
632 | via_write_reg(VIACR, 0x34, (addr >> 16) & 0xFF); | ||
633 | via_write_reg_mask(VIACR, 0x48, (addr >> 24) & 0x1F, 0x1F); | ||
634 | } | ||
635 | |||
636 | void via_set_secondary_address(u32 addr) | ||
637 | { | ||
638 | DEBUG_MSG(KERN_DEBUG "via_set_secondary_address(0x%08X)\n", addr); | ||
639 | /* secondary display supports only quadword aligned memory */ | ||
640 | via_write_reg_mask(VIACR, 0x62, (addr >> 2) & 0xFE, 0xFE); | ||
641 | via_write_reg(VIACR, 0x63, (addr >> 10) & 0xFF); | ||
642 | via_write_reg(VIACR, 0x64, (addr >> 18) & 0xFF); | ||
643 | via_write_reg_mask(VIACR, 0xA3, (addr >> 26) & 0x07, 0x07); | ||
644 | } | ||
645 | |||
646 | void via_set_primary_pitch(u32 pitch) | ||
647 | { | ||
648 | DEBUG_MSG(KERN_DEBUG "via_set_primary_pitch(0x%08X)\n", pitch); | ||
649 | /* spec does not say that first adapter skips 3 bits but old | ||
650 | * code did it and seems to be reasonable in analogy to 2nd adapter | ||
651 | */ | ||
652 | pitch = pitch >> 3; | ||
653 | via_write_reg(VIACR, 0x13, pitch & 0xFF); | ||
654 | via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0); | ||
655 | } | ||
656 | |||
657 | void via_set_secondary_pitch(u32 pitch) | ||
658 | { | ||
659 | DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch); | ||
660 | pitch = pitch >> 3; | ||
661 | via_write_reg(VIACR, 0x66, pitch & 0xFF); | ||
662 | via_write_reg_mask(VIACR, 0x67, (pitch >> 8) & 0x03, 0x03); | ||
663 | via_write_reg_mask(VIACR, 0x71, (pitch >> (10 - 7)) & 0x80, 0x80); | ||
664 | } | ||
665 | |||
666 | void via_set_primary_color_depth(u8 depth) | ||
667 | { | ||
668 | u8 value; | ||
669 | |||
670 | DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth); | ||
671 | switch (depth) { | ||
672 | case 8: | ||
673 | value = 0x00; | ||
674 | break; | ||
675 | case 15: | ||
676 | value = 0x04; | ||
677 | break; | ||
678 | case 16: | ||
679 | value = 0x14; | ||
680 | break; | ||
681 | case 24: | ||
682 | value = 0x0C; | ||
683 | break; | ||
684 | case 30: | ||
685 | value = 0x08; | ||
686 | break; | ||
687 | default: | ||
688 | printk(KERN_WARNING "via_set_primary_color_depth: " | ||
689 | "Unsupported depth: %d\n", depth); | ||
690 | return; | ||
691 | } | ||
692 | |||
693 | via_write_reg_mask(VIASR, 0x15, value, 0x1C); | ||
694 | } | ||
695 | |||
696 | void via_set_secondary_color_depth(u8 depth) | ||
697 | { | ||
698 | u8 value; | ||
699 | |||
700 | DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth); | ||
701 | switch (depth) { | ||
702 | case 8: | ||
703 | value = 0x00; | ||
704 | break; | ||
705 | case 16: | ||
706 | value = 0x40; | ||
707 | break; | ||
708 | case 24: | ||
709 | value = 0xC0; | ||
710 | break; | ||
711 | case 30: | ||
712 | value = 0x80; | ||
713 | break; | ||
714 | default: | ||
715 | printk(KERN_WARNING "via_set_secondary_color_depth: " | ||
716 | "Unsupported depth: %d\n", depth); | ||
717 | return; | ||
718 | } | ||
719 | |||
720 | via_write_reg_mask(VIACR, 0x67, value, 0xC0); | ||
721 | } | ||
722 | |||
723 | static void set_color_register(u8 index, u8 red, u8 green, u8 blue) | 627 | static void set_color_register(u8 index, u8 red, u8 green, u8 blue) |
724 | { | 628 | { |
725 | outb(0xFF, 0x3C6); /* bit mask of palette */ | 629 | outb(0xFF, 0x3C6); /* bit mask of palette */ |
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h index 641a5fa4bd33..a58701f3bf7f 100644 --- a/drivers/video/via/hw.h +++ b/drivers/video/via/hw.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "viamode.h" | 25 | #include "viamode.h" |
26 | #include "global.h" | 26 | #include "global.h" |
27 | #include "via_io.h" | 27 | #include "via_io.h" |
28 | #include "via_modesetting.h" | ||
28 | 29 | ||
29 | #define viafb_read_reg(p, i) via_read_reg(p, i) | 30 | #define viafb_read_reg(p, i) via_read_reg(p, i) |
30 | #define viafb_write_reg(i, p, d) via_write_reg(p, i, d) | 31 | #define viafb_write_reg(i, p, d) via_write_reg(p, i, d) |
@@ -910,10 +911,6 @@ void viafb_update_device_setting(int hres, int vres, int bpp, | |||
910 | int vmode_refresh, int flag); | 911 | int vmode_refresh, int flag); |
911 | 912 | ||
912 | void viafb_set_iga_path(void); | 913 | void viafb_set_iga_path(void); |
913 | void via_set_primary_address(u32 addr); | ||
914 | void via_set_secondary_address(u32 addr); | ||
915 | void via_set_primary_pitch(u32 pitch); | ||
916 | void via_set_secondary_pitch(u32 pitch); | ||
917 | void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue); | 914 | void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue); |
918 | void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue); | 915 | void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue); |
919 | void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len); | 916 | void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len); |
diff --git a/drivers/video/via/via_modesetting.c b/drivers/video/via/via_modesetting.c new file mode 100644 index 000000000000..69ff28575008 --- /dev/null +++ b/drivers/video/via/via_modesetting.c | |||
@@ -0,0 +1,126 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | * Copyright 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public | ||
8 | * License as published by the Free Software Foundation; | ||
9 | * either version 2, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
14 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
15 | * for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., | ||
20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
21 | */ | ||
22 | /* | ||
23 | * basic modesetting functions | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include "via_modesetting.h" | ||
28 | #include "via_io.h" | ||
29 | #include "share.h" | ||
30 | #include "debug.h" | ||
31 | |||
32 | void via_set_primary_address(u32 addr) | ||
33 | { | ||
34 | DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr); | ||
35 | via_write_reg(VIACR, 0x0D, addr & 0xFF); | ||
36 | via_write_reg(VIACR, 0x0C, (addr >> 8) & 0xFF); | ||
37 | via_write_reg(VIACR, 0x34, (addr >> 16) & 0xFF); | ||
38 | via_write_reg_mask(VIACR, 0x48, (addr >> 24) & 0x1F, 0x1F); | ||
39 | } | ||
40 | |||
41 | void via_set_secondary_address(u32 addr) | ||
42 | { | ||
43 | DEBUG_MSG(KERN_DEBUG "via_set_secondary_address(0x%08X)\n", addr); | ||
44 | /* secondary display supports only quadword aligned memory */ | ||
45 | via_write_reg_mask(VIACR, 0x62, (addr >> 2) & 0xFE, 0xFE); | ||
46 | via_write_reg(VIACR, 0x63, (addr >> 10) & 0xFF); | ||
47 | via_write_reg(VIACR, 0x64, (addr >> 18) & 0xFF); | ||
48 | via_write_reg_mask(VIACR, 0xA3, (addr >> 26) & 0x07, 0x07); | ||
49 | } | ||
50 | |||
51 | void via_set_primary_pitch(u32 pitch) | ||
52 | { | ||
53 | DEBUG_MSG(KERN_DEBUG "via_set_primary_pitch(0x%08X)\n", pitch); | ||
54 | /* spec does not say that first adapter skips 3 bits but old | ||
55 | * code did it and seems to be reasonable in analogy to 2nd adapter | ||
56 | */ | ||
57 | pitch = pitch >> 3; | ||
58 | via_write_reg(VIACR, 0x13, pitch & 0xFF); | ||
59 | via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0); | ||
60 | } | ||
61 | |||
62 | void via_set_secondary_pitch(u32 pitch) | ||
63 | { | ||
64 | DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch); | ||
65 | pitch = pitch >> 3; | ||
66 | via_write_reg(VIACR, 0x66, pitch & 0xFF); | ||
67 | via_write_reg_mask(VIACR, 0x67, (pitch >> 8) & 0x03, 0x03); | ||
68 | via_write_reg_mask(VIACR, 0x71, (pitch >> (10 - 7)) & 0x80, 0x80); | ||
69 | } | ||
70 | |||
71 | void via_set_primary_color_depth(u8 depth) | ||
72 | { | ||
73 | u8 value; | ||
74 | |||
75 | DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth); | ||
76 | switch (depth) { | ||
77 | case 8: | ||
78 | value = 0x00; | ||
79 | break; | ||
80 | case 15: | ||
81 | value = 0x04; | ||
82 | break; | ||
83 | case 16: | ||
84 | value = 0x14; | ||
85 | break; | ||
86 | case 24: | ||
87 | value = 0x0C; | ||
88 | break; | ||
89 | case 30: | ||
90 | value = 0x08; | ||
91 | break; | ||
92 | default: | ||
93 | printk(KERN_WARNING "via_set_primary_color_depth: " | ||
94 | "Unsupported depth: %d\n", depth); | ||
95 | return; | ||
96 | } | ||
97 | |||
98 | via_write_reg_mask(VIASR, 0x15, value, 0x1C); | ||
99 | } | ||
100 | |||
101 | void via_set_secondary_color_depth(u8 depth) | ||
102 | { | ||
103 | u8 value; | ||
104 | |||
105 | DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth); | ||
106 | switch (depth) { | ||
107 | case 8: | ||
108 | value = 0x00; | ||
109 | break; | ||
110 | case 16: | ||
111 | value = 0x40; | ||
112 | break; | ||
113 | case 24: | ||
114 | value = 0xC0; | ||
115 | break; | ||
116 | case 30: | ||
117 | value = 0x80; | ||
118 | break; | ||
119 | default: | ||
120 | printk(KERN_WARNING "via_set_secondary_color_depth: " | ||
121 | "Unsupported depth: %d\n", depth); | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | via_write_reg_mask(VIACR, 0x67, value, 0xC0); | ||
126 | } | ||
diff --git a/drivers/video/via/via_modesetting.h b/drivers/video/via/via_modesetting.h new file mode 100644 index 000000000000..ae35cfdeb37c --- /dev/null +++ b/drivers/video/via/via_modesetting.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | * Copyright 2010 Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public | ||
8 | * License as published by the Free Software Foundation; | ||
9 | * either version 2, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
14 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
15 | * for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., | ||
20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
21 | */ | ||
22 | /* | ||
23 | * basic modesetting functions | ||
24 | */ | ||
25 | |||
26 | #ifndef __VIA_MODESETTING_H__ | ||
27 | #define __VIA_MODESETTING_H__ | ||
28 | |||
29 | #include <linux/types.h> | ||
30 | |||
31 | void via_set_primary_address(u32 addr); | ||
32 | void via_set_secondary_address(u32 addr); | ||
33 | void via_set_primary_pitch(u32 pitch); | ||
34 | void via_set_secondary_pitch(u32 pitch); | ||
35 | void via_set_primary_color_depth(u8 depth); | ||
36 | void via_set_secondary_color_depth(u8 depth); | ||
37 | |||
38 | #endif /* __VIA_MODESETTING_H__ */ | ||