diff options
author | Joseph Chan <JosephChan@via.com.tw> | 2008-10-16 01:03:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:41 -0400 |
commit | c91b557ad0a4d4803874f8b908aa9732152b0f0b (patch) | |
tree | 7ad914c2deed6f71e2600bdfdb7cbc84ef22aa41 /drivers | |
parent | d61e0bf38e3e4adb2c775d64e447f6f9bef67075 (diff) |
viafb: iface.c, iface.h, ioctl.c, ioctl.h
iface.c, iface.h: support getting video memory from backdoor.
ioctl.c, ioctl.h: support user mode application with additional information
Signed-off-by: Joseph Chan <josephchan@via.com.tw>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/via/iface.c | 78 | ||||
-rw-r--r-- | drivers/video/via/iface.h | 38 | ||||
-rw-r--r-- | drivers/video/via/ioctl.c | 112 | ||||
-rw-r--r-- | drivers/video/via/ioctl.h | 210 |
4 files changed, 438 insertions, 0 deletions
diff --git a/drivers/video/via/iface.c b/drivers/video/via/iface.c new file mode 100644 index 000000000000..1570636c8d51 --- /dev/null +++ b/drivers/video/via/iface.c | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #include "global.h" | ||
23 | |||
24 | /* Get frame buffer size from VGA BIOS */ | ||
25 | |||
26 | unsigned int viafb_get_memsize(void) | ||
27 | { | ||
28 | unsigned int m; | ||
29 | |||
30 | /* If memory size provided by user */ | ||
31 | if (viafb_memsize) | ||
32 | m = viafb_memsize * Mb; | ||
33 | else { | ||
34 | m = (unsigned int)viafb_read_reg(VIASR, SR39); | ||
35 | m = m * (4 * Mb); | ||
36 | |||
37 | if ((m < (16 * Mb)) || (m > (64 * Mb))) | ||
38 | m = 16 * Mb; | ||
39 | } | ||
40 | DEBUG_MSG(KERN_INFO "framebuffer size = %d Mb\n", m / Mb); | ||
41 | return m; | ||
42 | } | ||
43 | |||
44 | /* Get Video Buffer Starting Physical Address(back door)*/ | ||
45 | |||
46 | unsigned long viafb_get_videobuf_addr(void) | ||
47 | { | ||
48 | struct pci_dev *pdev = NULL; | ||
49 | unsigned char sys_mem; | ||
50 | unsigned char video_mem; | ||
51 | unsigned long sys_mem_size; | ||
52 | unsigned long video_mem_size; | ||
53 | /*system memory = 256 MB, video memory 64 MB */ | ||
54 | unsigned long vmem_starting_adr = 0x0C000000; | ||
55 | |||
56 | pdev = | ||
57 | (struct pci_dev *)pci_get_device(VIA_K800_BRIDGE_VID, | ||
58 | VIA_K800_BRIDGE_DID, NULL); | ||
59 | if (pdev != NULL) { | ||
60 | pci_read_config_byte(pdev, VIA_K800_SYSTEM_MEMORY_REG, | ||
61 | &sys_mem); | ||
62 | pci_read_config_byte(pdev, VIA_K800_VIDEO_MEMORY_REG, | ||
63 | &video_mem); | ||
64 | video_mem = (video_mem & 0x70) >> 4; | ||
65 | sys_mem_size = ((unsigned long)sys_mem) << 24; | ||
66 | if (video_mem != 0) | ||
67 | video_mem_size = (1 << (video_mem)) * 1024 * 1024; | ||
68 | else | ||
69 | video_mem_size = 0; | ||
70 | |||
71 | vmem_starting_adr = sys_mem_size - video_mem_size; | ||
72 | pci_dev_put(pdev); | ||
73 | } | ||
74 | |||
75 | DEBUG_MSG(KERN_INFO "Video Memory Starting Address = %lx \n", | ||
76 | vmem_starting_adr); | ||
77 | return vmem_starting_adr; | ||
78 | } | ||
diff --git a/drivers/video/via/iface.h b/drivers/video/via/iface.h new file mode 100644 index 000000000000..790ec3e3aea2 --- /dev/null +++ b/drivers/video/via/iface.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 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef __IFACE_H__ | ||
23 | #define __IFACE_H__ | ||
24 | |||
25 | #define Kb (1024) | ||
26 | #define Mb (Kb*Kb) | ||
27 | |||
28 | #define VIA_K800_BRIDGE_VID 0x1106 | ||
29 | #define VIA_K800_BRIDGE_DID 0x3204 | ||
30 | |||
31 | #define VIA_K800_SYSTEM_MEMORY_REG 0x47 | ||
32 | #define VIA_K800_VIDEO_MEMORY_REG 0xA1 | ||
33 | |||
34 | extern int viafb_memsize; | ||
35 | unsigned int viafb_get_memsize(void); | ||
36 | unsigned long viafb_get_videobuf_addr(void); | ||
37 | |||
38 | #endif /* __IFACE_H__ */ | ||
diff --git a/drivers/video/via/ioctl.c b/drivers/video/via/ioctl.c new file mode 100644 index 000000000000..da03c074e32a --- /dev/null +++ b/drivers/video/via/ioctl.c | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #include "global.h" | ||
23 | |||
24 | int viafb_ioctl_get_viafb_info(u_long arg) | ||
25 | { | ||
26 | struct viafb_ioctl_info viainfo; | ||
27 | |||
28 | viainfo.viafb_id = VIAID; | ||
29 | viainfo.vendor_id = PCI_VIA_VENDOR_ID; | ||
30 | |||
31 | switch (viaparinfo->chip_info->gfx_chip_name) { | ||
32 | case UNICHROME_CLE266: | ||
33 | viainfo.device_id = UNICHROME_CLE266_DID; | ||
34 | break; | ||
35 | |||
36 | case UNICHROME_K400: | ||
37 | viainfo.device_id = UNICHROME_K400_DID; | ||
38 | break; | ||
39 | |||
40 | case UNICHROME_K800: | ||
41 | viainfo.device_id = UNICHROME_K800_DID; | ||
42 | break; | ||
43 | |||
44 | case UNICHROME_PM800: | ||
45 | viainfo.device_id = UNICHROME_PM800_DID; | ||
46 | break; | ||
47 | |||
48 | case UNICHROME_CN700: | ||
49 | viainfo.device_id = UNICHROME_CN700_DID; | ||
50 | break; | ||
51 | |||
52 | case UNICHROME_CX700: | ||
53 | viainfo.device_id = UNICHROME_CX700_DID; | ||
54 | break; | ||
55 | |||
56 | case UNICHROME_K8M890: | ||
57 | viainfo.device_id = UNICHROME_K8M890_DID; | ||
58 | break; | ||
59 | |||
60 | case UNICHROME_P4M890: | ||
61 | viainfo.device_id = UNICHROME_P4M890_DID; | ||
62 | break; | ||
63 | |||
64 | case UNICHROME_P4M900: | ||
65 | viainfo.device_id = UNICHROME_P4M900_DID; | ||
66 | break; | ||
67 | } | ||
68 | |||
69 | viainfo.version = VERSION_MAJOR; | ||
70 | viainfo.revision = VERSION_MINOR; | ||
71 | |||
72 | if (copy_to_user((void __user *)arg, &viainfo, sizeof(viainfo))) | ||
73 | return -EFAULT; | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | /* Hot-Plug Priority: DVI > CRT*/ | ||
79 | int viafb_ioctl_hotplug(int hres, int vres, int bpp) | ||
80 | { | ||
81 | int DVIsense, status = 0; | ||
82 | DEBUG_MSG(KERN_INFO "viafb_ioctl_hotplug!!\n"); | ||
83 | |||
84 | if (viaparinfo->chip_info->tmds_chip_info.tmds_chip_name != | ||
85 | NON_TMDS_TRANSMITTER) { | ||
86 | DVIsense = viafb_dvi_sense(); | ||
87 | |||
88 | if (DVIsense) { | ||
89 | DEBUG_MSG(KERN_INFO "DVI Attached...\n"); | ||
90 | if (viafb_DeviceStatus != DVI_Device) { | ||
91 | viafb_DVI_ON = 1; | ||
92 | viafb_CRT_ON = 0; | ||
93 | viafb_LCD_ON = 0; | ||
94 | viafb_DeviceStatus = DVI_Device; | ||
95 | return viafb_DeviceStatus; | ||
96 | } | ||
97 | status = 1; | ||
98 | } else | ||
99 | DEBUG_MSG(KERN_INFO "DVI De-attached...\n"); | ||
100 | } | ||
101 | |||
102 | if ((viafb_DeviceStatus != CRT_Device) && (status == 0)) { | ||
103 | viafb_CRT_ON = 1; | ||
104 | viafb_DVI_ON = 0; | ||
105 | viafb_LCD_ON = 0; | ||
106 | |||
107 | viafb_DeviceStatus = CRT_Device; | ||
108 | return viafb_DeviceStatus; | ||
109 | } | ||
110 | |||
111 | return 0; | ||
112 | } | ||
diff --git a/drivers/video/via/ioctl.h b/drivers/video/via/ioctl.h new file mode 100644 index 000000000000..842fe30b9868 --- /dev/null +++ b/drivers/video/via/ioctl.h | |||
@@ -0,0 +1,210 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef __IOCTL_H__ | ||
23 | #define __IOCTL_H__ | ||
24 | |||
25 | #ifndef __user | ||
26 | #define __user | ||
27 | #endif | ||
28 | |||
29 | /* VIAFB IOCTL definition */ | ||
30 | #define VIAFB_GET_INFO_SIZE 0x56494101 /* 'VIA\01' */ | ||
31 | #define VIAFB_GET_INFO 0x56494102 /* 'VIA\02' */ | ||
32 | #define VIAFB_HOTPLUG 0x56494103 /* 'VIA\03' */ | ||
33 | #define VIAFB_SET_HOTPLUG_FLAG 0x56494104 /* 'VIA\04' */ | ||
34 | #define VIAFB_GET_RESOLUTION 0x56494105 /* 'VIA\05' */ | ||
35 | #define VIAFB_GET_SAMM_INFO 0x56494107 /* 'VIA\07' */ | ||
36 | #define VIAFB_TURN_ON_OUTPUT_DEVICE 0x56494108 /* 'VIA\08' */ | ||
37 | #define VIAFB_TURN_OFF_OUTPUT_DEVICE 0x56494109 /* 'VIA\09' */ | ||
38 | #define VIAFB_SET_DEVICE 0x5649410A | ||
39 | #define VIAFB_GET_DEVICE 0x5649410B | ||
40 | #define VIAFB_GET_DRIVER_VERSION 0x56494112 /* 'VIA\12' */ | ||
41 | #define VIAFB_GET_CHIP_INFO 0x56494113 /* 'VIA\13' */ | ||
42 | #define VIAFB_SET_DEVICE_INFO 0x56494114 | ||
43 | #define VIAFB_GET_DEVICE_INFO 0x56494115 | ||
44 | |||
45 | #define VIAFB_GET_DEVICE_SUPPORT 0x56494118 | ||
46 | #define VIAFB_GET_DEVICE_CONNECT 0x56494119 | ||
47 | #define VIAFB_GET_PANEL_SUPPORT_EXPAND 0x5649411A | ||
48 | #define VIAFB_GET_DRIVER_NAME 0x56494122 | ||
49 | #define VIAFB_GET_DEVICE_SUPPORT_STATE 0x56494123 | ||
50 | #define VIAFB_GET_GAMMA_LUT 0x56494124 | ||
51 | #define VIAFB_SET_GAMMA_LUT 0x56494125 | ||
52 | #define VIAFB_GET_GAMMA_SUPPORT_STATE 0x56494126 | ||
53 | #define VIAFB_SET_VIDEO_DEVICE 0x56494127 | ||
54 | #define VIAFB_GET_VIDEO_DEVICE 0x56494128 | ||
55 | #define VIAFB_SET_SECOND_MODE 0x56494129 | ||
56 | #define VIAFB_SYNC_SURFACE 0x56494130 | ||
57 | #define VIAFB_GET_DRIVER_CAPS 0x56494131 | ||
58 | #define VIAFB_GET_IGA_SCALING_INFO 0x56494132 | ||
59 | #define VIAFB_GET_PANEL_MAX_SIZE 0x56494133 | ||
60 | #define VIAFB_GET_PANEL_MAX_POSITION 0x56494134 | ||
61 | #define VIAFB_SET_PANEL_SIZE 0x56494135 | ||
62 | #define VIAFB_SET_PANEL_POSITION 0x56494136 | ||
63 | #define VIAFB_GET_PANEL_POSITION 0x56494137 | ||
64 | #define VIAFB_GET_PANEL_SIZE 0x56494138 | ||
65 | |||
66 | #define None_Device 0x00 | ||
67 | #define CRT_Device 0x01 | ||
68 | #define LCD_Device 0x02 | ||
69 | #define DVI_Device 0x08 | ||
70 | #define CRT2_Device 0x10 | ||
71 | #define LCD2_Device 0x40 | ||
72 | |||
73 | #define OP_LCD_CENTERING 0x01 | ||
74 | #define OP_LCD_PANEL_ID 0x02 | ||
75 | #define OP_LCD_MODE 0x03 | ||
76 | |||
77 | /*SAMM operation flag*/ | ||
78 | #define OP_SAMM 0x80 | ||
79 | |||
80 | #define LCD_PANEL_ID_MAXIMUM 22 | ||
81 | |||
82 | #define STATE_ON 0x1 | ||
83 | #define STATE_OFF 0x0 | ||
84 | #define STATE_DEFAULT 0xFFFF | ||
85 | |||
86 | #define MAX_ACTIVE_DEV_NUM 2 | ||
87 | |||
88 | struct device_t { | ||
89 | unsigned short crt:1; | ||
90 | unsigned short dvi:1; | ||
91 | unsigned short lcd:1; | ||
92 | unsigned short samm:1; | ||
93 | unsigned short lcd_dsp_cent:1; | ||
94 | unsigned char lcd_mode:1; | ||
95 | unsigned short epia_dvi:1; | ||
96 | unsigned short lcd_dual_edge:1; | ||
97 | unsigned short lcd2:1; | ||
98 | |||
99 | unsigned short primary_dev; | ||
100 | unsigned char lcd_panel_id; | ||
101 | unsigned short xres, yres; | ||
102 | unsigned short xres1, yres1; | ||
103 | unsigned short refresh; | ||
104 | unsigned short bpp; | ||
105 | unsigned short refresh1; | ||
106 | unsigned short bpp1; | ||
107 | unsigned short sequence; | ||
108 | unsigned short bus_width; | ||
109 | }; | ||
110 | |||
111 | struct viafb_ioctl_info { | ||
112 | u32 viafb_id; /* for identifying viafb */ | ||
113 | #define VIAID 0x56494146 /* Identify myself with 'VIAF' */ | ||
114 | u16 vendor_id; | ||
115 | u16 device_id; | ||
116 | u8 version; | ||
117 | u8 revision; | ||
118 | u8 reserved[246]; /* for future use */ | ||
119 | }; | ||
120 | |||
121 | struct viafb_ioctl_mode { | ||
122 | u32 xres; | ||
123 | u32 yres; | ||
124 | u32 refresh; | ||
125 | u32 bpp; | ||
126 | u32 xres_sec; | ||
127 | u32 yres_sec; | ||
128 | u32 virtual_xres_sec; | ||
129 | u32 virtual_yres_sec; | ||
130 | u32 refresh_sec; | ||
131 | u32 bpp_sec; | ||
132 | }; | ||
133 | struct viafb_ioctl_samm { | ||
134 | u32 samm_status; | ||
135 | u32 size_prim; | ||
136 | u32 size_sec; | ||
137 | u32 mem_base; | ||
138 | u32 offset_sec; | ||
139 | }; | ||
140 | |||
141 | struct viafb_driver_version { | ||
142 | int iMajorNum; | ||
143 | int iKernelNum; | ||
144 | int iOSNum; | ||
145 | int iMinorNum; | ||
146 | }; | ||
147 | |||
148 | struct viafb_ioctl_lcd_attribute { | ||
149 | unsigned int panel_id; | ||
150 | unsigned int display_center; | ||
151 | unsigned int lcd_mode; | ||
152 | }; | ||
153 | |||
154 | struct viafb_ioctl_setting { | ||
155 | /* Enable or disable active devices */ | ||
156 | unsigned short device_flag; | ||
157 | /* Indicate which device should be turn on or turn off. */ | ||
158 | unsigned short device_status; | ||
159 | unsigned int reserved; | ||
160 | /* Indicate which LCD's attribute can be changed. */ | ||
161 | unsigned short lcd_operation_flag; | ||
162 | /* 1: SAMM ON 0: SAMM OFF */ | ||
163 | unsigned short samm_status; | ||
164 | /* horizontal resolution of first device */ | ||
165 | unsigned short first_dev_hor_res; | ||
166 | /* vertical resolution of first device */ | ||
167 | unsigned short first_dev_ver_res; | ||
168 | /* horizontal resolution of second device */ | ||
169 | unsigned short second_dev_hor_res; | ||
170 | /* vertical resolution of second device */ | ||
171 | unsigned short second_dev_ver_res; | ||
172 | /* refresh rate of first device */ | ||
173 | unsigned short first_dev_refresh; | ||
174 | /* bpp of first device */ | ||
175 | unsigned short first_dev_bpp; | ||
176 | /* refresh rate of second device */ | ||
177 | unsigned short second_dev_refresh; | ||
178 | /* bpp of second device */ | ||
179 | unsigned short second_dev_bpp; | ||
180 | /* Indicate which device are primary display device. */ | ||
181 | unsigned int primary_device; | ||
182 | /* Indicate which device will show video. only valid in duoview mode */ | ||
183 | unsigned int video_device_status; | ||
184 | unsigned int struct_reserved[34]; | ||
185 | struct viafb_ioctl_lcd_attribute lcd_attributes; | ||
186 | }; | ||
187 | |||
188 | struct _UTFunctionCaps { | ||
189 | unsigned int dw3DScalingState; | ||
190 | unsigned int reserved[31]; | ||
191 | }; | ||
192 | |||
193 | struct _POSITIONVALUE { | ||
194 | unsigned int dwX; | ||
195 | unsigned int dwY; | ||
196 | }; | ||
197 | |||
198 | struct _panel_size_pos_info { | ||
199 | unsigned int device_type; | ||
200 | int x; | ||
201 | int y; | ||
202 | }; | ||
203 | |||
204 | extern int viafb_LCD_ON; | ||
205 | extern int viafb_DVI_ON; | ||
206 | |||
207 | int viafb_ioctl_get_viafb_info(u_long arg); | ||
208 | int viafb_ioctl_hotplug(int hres, int vres, int bpp); | ||
209 | |||
210 | #endif /* __IOCTL_H__ */ | ||