Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1 | /* |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 2 | * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 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 <linux/module.h> |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 23 | #include <linux/seq_file.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 24 | #include <linux/slab.h> |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 25 | #include <linux/stat.h> |
Jonathan Corbet | ec66841 | 2010-05-05 14:44:55 -0600 | [diff] [blame] | 26 | #include <linux/via-core.h> |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 27 | |
Jonathan Corbet | ec66841 | 2010-05-05 14:44:55 -0600 | [diff] [blame] | 28 | #define _MASTER_FILE |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 29 | #include "global.h" |
| 30 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 31 | static char *viafb_name = "Via"; |
| 32 | static u32 pseudo_pal[17]; |
| 33 | |
| 34 | /* video mode */ |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 35 | static char *viafb_mode; |
| 36 | static char *viafb_mode1; |
Florian Tobias Schandinat | dba77f8 | 2010-03-10 15:21:37 -0800 | [diff] [blame] | 37 | static int viafb_bpp = 32; |
| 38 | static int viafb_bpp1 = 32; |
| 39 | |
| 40 | static unsigned int viafb_second_offset; |
| 41 | static int viafb_second_size; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 42 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 43 | static int viafb_accel = 1; |
| 44 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 45 | /* Added for specifying active devices.*/ |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 46 | char *viafb_active_dev; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 47 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 48 | /*Added for specify lcd output port*/ |
| 49 | char *viafb_lcd_port = ""; |
| 50 | char *viafb_dvi_port = ""; |
| 51 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 52 | static void retrieve_device_setting(struct viafb_ioctl_setting |
| 53 | *setting_info); |
Florian Tobias Schandinat | ee79d54 | 2010-03-10 15:21:32 -0800 | [diff] [blame] | 54 | static int viafb_pan_display(struct fb_var_screeninfo *var, |
| 55 | struct fb_info *info); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 56 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 57 | static struct fb_ops viafb_ops; |
| 58 | |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 59 | /* supported output devices on each IGP |
Florian Tobias Schandinat | 51f4332 | 2010-10-24 04:02:14 +0000 | [diff] [blame] | 60 | * only CX700, VX800, VX855, VX900 were documented |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 61 | * VIA_CRT should be everywhere |
| 62 | * VIA_6C can be onle pre-CX700 (probably only on CLE266) as 6C is used for PLL |
| 63 | * source selection on CX700 and later |
| 64 | * K400 seems to support VIA_96, VIA_DVP1, VIA_LVDS{1,2} as in viamode.c |
| 65 | */ |
| 66 | static const u32 supported_odev_map[] = { |
Florian Tobias Schandinat | a2aa9f9 | 2010-09-19 04:40:15 +0000 | [diff] [blame] | 67 | [UNICHROME_CLE266] = VIA_CRT | VIA_LDVP0 | VIA_LDVP1, |
| 68 | [UNICHROME_K400] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 69 | | VIA_LVDS2, |
Florian Tobias Schandinat | a2aa9f9 | 2010-09-19 04:40:15 +0000 | [diff] [blame] | 70 | [UNICHROME_K800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 71 | | VIA_LVDS2, |
Florian Tobias Schandinat | a2aa9f9 | 2010-09-19 04:40:15 +0000 | [diff] [blame] | 72 | [UNICHROME_PM800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 73 | | VIA_LVDS2, |
Florian Tobias Schandinat | a2aa9f9 | 2010-09-19 04:40:15 +0000 | [diff] [blame] | 74 | [UNICHROME_CN700] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1 |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 75 | | VIA_LVDS2, |
| 76 | [UNICHROME_CX700] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, |
| 77 | [UNICHROME_CN750] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, |
| 78 | [UNICHROME_K8M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, |
| 79 | [UNICHROME_P4M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, |
| 80 | [UNICHROME_P4M900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, |
| 81 | [UNICHROME_VX800] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, |
| 82 | [UNICHROME_VX855] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, |
Florian Tobias Schandinat | 51f4332 | 2010-10-24 04:02:14 +0000 | [diff] [blame] | 83 | [UNICHROME_VX900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2, |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 84 | }; |
Florian Tobias Schandinat | 81228a3 | 2009-09-22 16:47:13 -0700 | [diff] [blame] | 85 | |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 86 | static void viafb_fill_var_color_info(struct fb_var_screeninfo *var, u8 depth) |
| 87 | { |
| 88 | var->grayscale = 0; |
| 89 | var->red.msb_right = 0; |
| 90 | var->green.msb_right = 0; |
| 91 | var->blue.msb_right = 0; |
| 92 | var->transp.offset = 0; |
| 93 | var->transp.length = 0; |
| 94 | var->transp.msb_right = 0; |
| 95 | var->nonstd = 0; |
| 96 | switch (depth) { |
| 97 | case 8: |
| 98 | var->bits_per_pixel = 8; |
| 99 | var->red.offset = 0; |
| 100 | var->green.offset = 0; |
| 101 | var->blue.offset = 0; |
Florian Tobias Schandinat | 415559f | 2010-03-10 15:21:40 -0800 | [diff] [blame] | 102 | var->red.length = 8; |
| 103 | var->green.length = 8; |
| 104 | var->blue.length = 8; |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 105 | break; |
Florian Tobias Schandinat | e17cea3 | 2010-03-10 15:21:41 -0800 | [diff] [blame] | 106 | case 15: |
| 107 | var->bits_per_pixel = 16; |
| 108 | var->red.offset = 10; |
| 109 | var->green.offset = 5; |
| 110 | var->blue.offset = 0; |
| 111 | var->red.length = 5; |
| 112 | var->green.length = 5; |
| 113 | var->blue.length = 5; |
| 114 | break; |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 115 | case 16: |
| 116 | var->bits_per_pixel = 16; |
| 117 | var->red.offset = 11; |
| 118 | var->green.offset = 5; |
| 119 | var->blue.offset = 0; |
| 120 | var->red.length = 5; |
| 121 | var->green.length = 6; |
| 122 | var->blue.length = 5; |
| 123 | break; |
| 124 | case 24: |
| 125 | var->bits_per_pixel = 32; |
| 126 | var->red.offset = 16; |
| 127 | var->green.offset = 8; |
| 128 | var->blue.offset = 0; |
| 129 | var->red.length = 8; |
| 130 | var->green.length = 8; |
| 131 | var->blue.length = 8; |
| 132 | break; |
Florian Tobias Schandinat | e17cea3 | 2010-03-10 15:21:41 -0800 | [diff] [blame] | 133 | case 30: |
| 134 | var->bits_per_pixel = 32; |
| 135 | var->red.offset = 20; |
| 136 | var->green.offset = 10; |
| 137 | var->blue.offset = 0; |
| 138 | var->red.length = 10; |
| 139 | var->green.length = 10; |
| 140 | var->blue.length = 10; |
| 141 | break; |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | |
Florian Tobias Schandinat | 81228a3 | 2009-09-22 16:47:13 -0700 | [diff] [blame] | 145 | static void viafb_update_fix(struct fb_info *info) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 146 | { |
Florian Tobias Schandinat | 81228a3 | 2009-09-22 16:47:13 -0700 | [diff] [blame] | 147 | u32 bpp = info->var.bits_per_pixel; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 148 | |
Florian Tobias Schandinat | 81228a3 | 2009-09-22 16:47:13 -0700 | [diff] [blame] | 149 | info->fix.visual = |
| 150 | bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
Florian Tobias Schandinat | dbb7884 | 2010-03-10 15:21:39 -0800 | [diff] [blame] | 151 | info->fix.line_length = (info->var.xres_virtual * bpp / 8 + 7) & ~7; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 154 | static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix, |
| 155 | struct viafb_par *viaparinfo) |
| 156 | { |
| 157 | memset(fix, 0, sizeof(struct fb_fix_screeninfo)); |
| 158 | strcpy(fix->id, viafb_name); |
| 159 | |
| 160 | fix->smem_start = viaparinfo->fbmem; |
| 161 | fix->smem_len = viaparinfo->fbmem_free; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 162 | |
| 163 | fix->type = FB_TYPE_PACKED_PIXELS; |
| 164 | fix->type_aux = 0; |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 165 | fix->visual = FB_VISUAL_TRUECOLOR; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 166 | |
| 167 | fix->xpanstep = fix->ywrapstep = 0; |
| 168 | fix->ypanstep = 1; |
| 169 | |
| 170 | /* Just tell the accel name */ |
| 171 | viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME; |
| 172 | } |
| 173 | static int viafb_open(struct fb_info *info, int user) |
| 174 | { |
| 175 | DEBUG_MSG(KERN_INFO "viafb_open!\n"); |
| 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | static int viafb_release(struct fb_info *info, int user) |
| 180 | { |
| 181 | DEBUG_MSG(KERN_INFO "viafb_release!\n"); |
| 182 | return 0; |
| 183 | } |
| 184 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 185 | static int viafb_check_var(struct fb_var_screeninfo *var, |
| 186 | struct fb_info *info) |
| 187 | { |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 188 | int htotal, vtotal, depth; |
Florian Tobias Schandinat | dd73d68 | 2010-03-10 15:21:28 -0800 | [diff] [blame] | 189 | struct VideoModeTable *vmode_entry; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 190 | struct viafb_par *ppar = info->par; |
Florian Tobias Schandinat | dbb7884 | 2010-03-10 15:21:39 -0800 | [diff] [blame] | 191 | u32 long_refresh, line; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 192 | |
| 193 | DEBUG_MSG(KERN_INFO "viafb_check_var!\n"); |
| 194 | /* Sanity check */ |
| 195 | /* HW neither support interlacte nor double-scaned mode */ |
| 196 | if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE) |
| 197 | return -EINVAL; |
| 198 | |
Florian Tobias Schandinat | dd73d68 | 2010-03-10 15:21:28 -0800 | [diff] [blame] | 199 | vmode_entry = viafb_get_mode(var->xres, var->yres); |
| 200 | if (!vmode_entry) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 201 | DEBUG_MSG(KERN_INFO |
| 202 | "viafb: Mode %dx%dx%d not supported!!\n", |
| 203 | var->xres, var->yres, var->bits_per_pixel); |
| 204 | return -EINVAL; |
| 205 | } |
| 206 | |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 207 | depth = fb_get_color_depth(var, &info->fix); |
| 208 | if (!depth) |
| 209 | depth = var->bits_per_pixel; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 210 | |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 211 | if (depth < 0 || depth > 32) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 212 | return -EINVAL; |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 213 | else if (!depth) |
| 214 | depth = 24; |
Florian Tobias Schandinat | e17cea3 | 2010-03-10 15:21:41 -0800 | [diff] [blame] | 215 | else if (depth == 15 && viafb_dual_fb && ppar->iga_path == IGA1) |
| 216 | depth = 15; |
| 217 | else if (depth == 30) |
| 218 | depth = 30; |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 219 | else if (depth <= 8) |
| 220 | depth = 8; |
| 221 | else if (depth <= 16) |
| 222 | depth = 16; |
| 223 | else |
| 224 | depth = 24; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 225 | |
Florian Tobias Schandinat | bd14069 | 2010-03-10 15:21:38 -0800 | [diff] [blame] | 226 | viafb_fill_var_color_info(var, depth); |
Florian Tobias Schandinat | dbb7884 | 2010-03-10 15:21:39 -0800 | [diff] [blame] | 227 | line = (var->xres_virtual * var->bits_per_pixel / 8 + 7) & ~7; |
| 228 | if (line * var->yres_virtual > ppar->memsize) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 229 | return -EINVAL; |
| 230 | |
| 231 | /* Based on var passed in to calculate the refresh, |
| 232 | * because our driver use some modes special. |
| 233 | */ |
| 234 | htotal = var->xres + var->left_margin + |
| 235 | var->right_margin + var->hsync_len; |
| 236 | vtotal = var->yres + var->upper_margin + |
| 237 | var->lower_margin + var->vsync_len; |
| 238 | long_refresh = 1000000000UL / var->pixclock * 1000; |
| 239 | long_refresh /= (htotal * vtotal); |
| 240 | |
| 241 | viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh); |
| 242 | |
| 243 | /* Adjust var according to our driver's own table */ |
Florian Tobias Schandinat | dd73d68 | 2010-03-10 15:21:28 -0800 | [diff] [blame] | 244 | viafb_fill_var_timing_info(var, viafb_refresh, vmode_entry); |
Florian Tobias Schandinat | af29a5b | 2010-07-23 11:32:25 +0000 | [diff] [blame] | 245 | if (var->accel_flags & FB_ACCELF_TEXT && |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 246 | !ppar->shared->vdev->engine_mmio) |
Florian Tobias Schandinat | af29a5b | 2010-07-23 11:32:25 +0000 | [diff] [blame] | 247 | var->accel_flags = 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 248 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 249 | return 0; |
| 250 | } |
| 251 | |
| 252 | static int viafb_set_par(struct fb_info *info) |
| 253 | { |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 254 | struct viafb_par *viapar = info->par; |
Florian Tobias Schandinat | dd73d68 | 2010-03-10 15:21:28 -0800 | [diff] [blame] | 255 | struct VideoModeTable *vmode_entry, *vmode_entry1 = NULL; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 256 | DEBUG_MSG(KERN_INFO "viafb_set_par!\n"); |
| 257 | |
Florian Tobias Schandinat | 65123c6 | 2010-07-13 17:58:06 +0000 | [diff] [blame] | 258 | viafb_update_fix(info); |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 259 | viapar->depth = fb_get_color_depth(&info->var, &info->fix); |
Florian Tobias Schandinat | 5c9443e | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 260 | viafb_update_device_setting(viafbinfo->var.xres, viafbinfo->var.yres, |
| 261 | viafbinfo->var.bits_per_pixel, viafb_refresh, 0); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 262 | |
Florian Tobias Schandinat | 5c9443e | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 263 | vmode_entry = viafb_get_mode(viafbinfo->var.xres, viafbinfo->var.yres); |
| 264 | if (viafb_dual_fb) { |
| 265 | vmode_entry1 = viafb_get_mode(viafbinfo1->var.xres, |
| 266 | viafbinfo1->var.yres); |
| 267 | viafb_update_device_setting(viafbinfo1->var.xres, |
| 268 | viafbinfo1->var.yres, viafbinfo1->var.bits_per_pixel, |
| 269 | viafb_refresh1, 1); |
| 270 | } else if (viafb_SAMM_ON == 1) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 271 | DEBUG_MSG(KERN_INFO |
| 272 | "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n", |
| 273 | viafb_second_xres, viafb_second_yres, viafb_bpp1); |
Florian Tobias Schandinat | dd73d68 | 2010-03-10 15:21:28 -0800 | [diff] [blame] | 274 | vmode_entry1 = viafb_get_mode(viafb_second_xres, |
Florian Tobias Schandinat | 5215944 | 2009-08-06 15:07:34 -0700 | [diff] [blame] | 275 | viafb_second_yres); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 276 | |
| 277 | viafb_update_device_setting(viafb_second_xres, |
| 278 | viafb_second_yres, viafb_bpp1, viafb_refresh1, 1); |
| 279 | } |
| 280 | |
Florian Tobias Schandinat | dd73d68 | 2010-03-10 15:21:28 -0800 | [diff] [blame] | 281 | if (vmode_entry) { |
Florian Tobias Schandinat | 5c9443e | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 282 | if (viafb_dual_fb && viapar->iga_path == IGA2) |
| 283 | viafb_bpp1 = info->var.bits_per_pixel; |
| 284 | else |
| 285 | viafb_bpp = info->var.bits_per_pixel; |
| 286 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 287 | if (info->var.accel_flags & FB_ACCELF_TEXT) |
| 288 | info->flags &= ~FBINFO_HWACCEL_DISABLED; |
| 289 | else |
| 290 | info->flags |= FBINFO_HWACCEL_DISABLED; |
Florian Tobias Schandinat | dd73d68 | 2010-03-10 15:21:28 -0800 | [diff] [blame] | 291 | viafb_setmode(vmode_entry, info->var.bits_per_pixel, |
| 292 | vmode_entry1, viafb_bpp1); |
Florian Tobias Schandinat | ee79d54 | 2010-03-10 15:21:32 -0800 | [diff] [blame] | 293 | viafb_pan_display(&info->var, info); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | /* Set one color register */ |
| 300 | static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green, |
| 301 | unsigned blue, unsigned transp, struct fb_info *info) |
| 302 | { |
Florian Tobias Schandinat | 415559f | 2010-03-10 15:21:40 -0800 | [diff] [blame] | 303 | struct viafb_par *viapar = info->par; |
| 304 | u32 r, g, b; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 305 | |
Florian Tobias Schandinat | 415559f | 2010-03-10 15:21:40 -0800 | [diff] [blame] | 306 | if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) { |
| 307 | if (regno > 255) |
| 308 | return -EINVAL; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 309 | |
Florian Tobias Schandinat | 415559f | 2010-03-10 15:21:40 -0800 | [diff] [blame] | 310 | if (!viafb_dual_fb || viapar->iga_path == IGA1) |
| 311 | viafb_set_primary_color_register(regno, red >> 8, |
| 312 | green >> 8, blue >> 8); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 313 | |
Florian Tobias Schandinat | 415559f | 2010-03-10 15:21:40 -0800 | [diff] [blame] | 314 | if (!viafb_dual_fb || viapar->iga_path == IGA2) |
| 315 | viafb_set_secondary_color_register(regno, red >> 8, |
| 316 | green >> 8, blue >> 8); |
| 317 | } else { |
| 318 | if (regno > 15) |
| 319 | return -EINVAL; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 320 | |
Florian Tobias Schandinat | 415559f | 2010-03-10 15:21:40 -0800 | [diff] [blame] | 321 | r = (red >> (16 - info->var.red.length)) |
| 322 | << info->var.red.offset; |
| 323 | b = (blue >> (16 - info->var.blue.length)) |
| 324 | << info->var.blue.offset; |
| 325 | g = (green >> (16 - info->var.green.length)) |
| 326 | << info->var.green.offset; |
| 327 | ((u32 *) info->pseudo_palette)[regno] = r | g | b; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | return 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | static int viafb_pan_display(struct fb_var_screeninfo *var, |
| 334 | struct fb_info *info) |
| 335 | { |
Florian Tobias Schandinat | ee79d54 | 2010-03-10 15:21:32 -0800 | [diff] [blame] | 336 | struct viafb_par *viapar = info->par; |
| 337 | u32 vram_addr = (var->yoffset * var->xres_virtual + var->xoffset) |
| 338 | * (var->bits_per_pixel / 8) + viapar->vram_addr; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 339 | |
Florian Tobias Schandinat | ee79d54 | 2010-03-10 15:21:32 -0800 | [diff] [blame] | 340 | DEBUG_MSG(KERN_DEBUG "viafb_pan_display, address = %d\n", vram_addr); |
| 341 | if (!viafb_dual_fb) { |
Florian Tobias Schandinat | 2749413 | 2010-04-17 19:44:52 +0000 | [diff] [blame] | 342 | via_set_primary_address(vram_addr); |
| 343 | via_set_secondary_address(vram_addr); |
Florian Tobias Schandinat | ee79d54 | 2010-03-10 15:21:32 -0800 | [diff] [blame] | 344 | } else if (viapar->iga_path == IGA1) |
Florian Tobias Schandinat | 2749413 | 2010-04-17 19:44:52 +0000 | [diff] [blame] | 345 | via_set_primary_address(vram_addr); |
Florian Tobias Schandinat | ee79d54 | 2010-03-10 15:21:32 -0800 | [diff] [blame] | 346 | else |
Florian Tobias Schandinat | 2749413 | 2010-04-17 19:44:52 +0000 | [diff] [blame] | 347 | via_set_secondary_address(vram_addr); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 348 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 349 | return 0; |
| 350 | } |
| 351 | |
| 352 | static int viafb_blank(int blank_mode, struct fb_info *info) |
| 353 | { |
| 354 | DEBUG_MSG(KERN_INFO "viafb_blank!\n"); |
| 355 | /* clear DPMS setting */ |
| 356 | |
| 357 | switch (blank_mode) { |
| 358 | case FB_BLANK_UNBLANK: |
| 359 | /* Screen: On, HSync: On, VSync: On */ |
| 360 | /* control CRT monitor power management */ |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 361 | via_set_state(VIA_CRT, VIA_STATE_ON); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 362 | break; |
| 363 | case FB_BLANK_HSYNC_SUSPEND: |
| 364 | /* Screen: Off, HSync: Off, VSync: On */ |
| 365 | /* control CRT monitor power management */ |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 366 | via_set_state(VIA_CRT, VIA_STATE_STANDBY); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 367 | break; |
| 368 | case FB_BLANK_VSYNC_SUSPEND: |
| 369 | /* Screen: Off, HSync: On, VSync: Off */ |
| 370 | /* control CRT monitor power management */ |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 371 | via_set_state(VIA_CRT, VIA_STATE_SUSPEND); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 372 | break; |
| 373 | case FB_BLANK_POWERDOWN: |
| 374 | /* Screen: Off, HSync: Off, VSync: Off */ |
| 375 | /* control CRT monitor power management */ |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 376 | via_set_state(VIA_CRT, VIA_STATE_OFF); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 377 | break; |
| 378 | } |
| 379 | |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) |
| 384 | { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 385 | union { |
| 386 | struct viafb_ioctl_mode viamode; |
| 387 | struct viafb_ioctl_samm viasamm; |
| 388 | struct viafb_driver_version driver_version; |
| 389 | struct fb_var_screeninfo sec_var; |
| 390 | struct _panel_size_pos_info panel_pos_size_para; |
| 391 | struct viafb_ioctl_setting viafb_setting; |
| 392 | struct device_t active_dev; |
| 393 | } u; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 394 | u32 state_info = 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 395 | u32 *viafb_gamma_table; |
| 396 | char driver_name[] = "viafb"; |
| 397 | |
| 398 | u32 __user *argp = (u32 __user *) arg; |
| 399 | u32 gpu32; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 400 | |
| 401 | DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd); |
Florian Tobias Schandinat | cc8b82f | 2010-03-10 15:21:26 -0800 | [diff] [blame] | 402 | printk(KERN_WARNING "viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n"); |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 403 | memset(&u, 0, sizeof(u)); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 404 | |
| 405 | switch (cmd) { |
| 406 | case VIAFB_GET_CHIP_INFO: |
| 407 | if (copy_to_user(argp, viaparinfo->chip_info, |
| 408 | sizeof(struct chip_information))) |
| 409 | return -EFAULT; |
| 410 | break; |
| 411 | case VIAFB_GET_INFO_SIZE: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 412 | return put_user((u32)sizeof(struct viafb_ioctl_info), argp); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 413 | case VIAFB_GET_INFO: |
| 414 | return viafb_ioctl_get_viafb_info(arg); |
| 415 | case VIAFB_HOTPLUG: |
| 416 | return put_user(viafb_ioctl_hotplug(info->var.xres, |
| 417 | info->var.yres, |
| 418 | info->var.bits_per_pixel), argp); |
| 419 | case VIAFB_SET_HOTPLUG_FLAG: |
| 420 | if (copy_from_user(&gpu32, argp, sizeof(gpu32))) |
| 421 | return -EFAULT; |
| 422 | viafb_hotplug = (gpu32) ? 1 : 0; |
| 423 | break; |
| 424 | case VIAFB_GET_RESOLUTION: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 425 | u.viamode.xres = (u32) viafb_hotplug_Xres; |
| 426 | u.viamode.yres = (u32) viafb_hotplug_Yres; |
| 427 | u.viamode.refresh = (u32) viafb_hotplug_refresh; |
| 428 | u.viamode.bpp = (u32) viafb_hotplug_bpp; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 429 | if (viafb_SAMM_ON == 1) { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 430 | u.viamode.xres_sec = viafb_second_xres; |
| 431 | u.viamode.yres_sec = viafb_second_yres; |
| 432 | u.viamode.virtual_xres_sec = viafb_second_virtual_xres; |
| 433 | u.viamode.virtual_yres_sec = viafb_second_virtual_yres; |
| 434 | u.viamode.refresh_sec = viafb_refresh1; |
| 435 | u.viamode.bpp_sec = viafb_bpp1; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 436 | } else { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 437 | u.viamode.xres_sec = 0; |
| 438 | u.viamode.yres_sec = 0; |
| 439 | u.viamode.virtual_xres_sec = 0; |
| 440 | u.viamode.virtual_yres_sec = 0; |
| 441 | u.viamode.refresh_sec = 0; |
| 442 | u.viamode.bpp_sec = 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 443 | } |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 444 | if (copy_to_user(argp, &u.viamode, sizeof(u.viamode))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 445 | return -EFAULT; |
| 446 | break; |
| 447 | case VIAFB_GET_SAMM_INFO: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 448 | u.viasamm.samm_status = viafb_SAMM_ON; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 449 | |
| 450 | if (viafb_SAMM_ON == 1) { |
| 451 | if (viafb_dual_fb) { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 452 | u.viasamm.size_prim = viaparinfo->fbmem_free; |
| 453 | u.viasamm.size_sec = viaparinfo1->fbmem_free; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 454 | } else { |
| 455 | if (viafb_second_size) { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 456 | u.viasamm.size_prim = |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 457 | viaparinfo->fbmem_free - |
| 458 | viafb_second_size * 1024 * 1024; |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 459 | u.viasamm.size_sec = |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 460 | viafb_second_size * 1024 * 1024; |
| 461 | } else { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 462 | u.viasamm.size_prim = |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 463 | viaparinfo->fbmem_free >> 1; |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 464 | u.viasamm.size_sec = |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 465 | (viaparinfo->fbmem_free >> 1); |
| 466 | } |
| 467 | } |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 468 | u.viasamm.mem_base = viaparinfo->fbmem; |
| 469 | u.viasamm.offset_sec = viafb_second_offset; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 470 | } else { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 471 | u.viasamm.size_prim = |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 472 | viaparinfo->memsize - viaparinfo->fbmem_used; |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 473 | u.viasamm.size_sec = 0; |
| 474 | u.viasamm.mem_base = viaparinfo->fbmem; |
| 475 | u.viasamm.offset_sec = 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 476 | } |
| 477 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 478 | if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 479 | return -EFAULT; |
| 480 | |
| 481 | break; |
| 482 | case VIAFB_TURN_ON_OUTPUT_DEVICE: |
| 483 | if (copy_from_user(&gpu32, argp, sizeof(gpu32))) |
| 484 | return -EFAULT; |
| 485 | if (gpu32 & CRT_Device) |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 486 | via_set_state(VIA_CRT, VIA_STATE_ON); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 487 | if (gpu32 & DVI_Device) |
| 488 | viafb_dvi_enable(); |
| 489 | if (gpu32 & LCD_Device) |
| 490 | viafb_lcd_enable(); |
| 491 | break; |
| 492 | case VIAFB_TURN_OFF_OUTPUT_DEVICE: |
| 493 | if (copy_from_user(&gpu32, argp, sizeof(gpu32))) |
| 494 | return -EFAULT; |
| 495 | if (gpu32 & CRT_Device) |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 496 | via_set_state(VIA_CRT, VIA_STATE_OFF); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 497 | if (gpu32 & DVI_Device) |
| 498 | viafb_dvi_disable(); |
| 499 | if (gpu32 & LCD_Device) |
| 500 | viafb_lcd_disable(); |
| 501 | break; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 502 | case VIAFB_GET_DEVICE: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 503 | u.active_dev.crt = viafb_CRT_ON; |
| 504 | u.active_dev.dvi = viafb_DVI_ON; |
| 505 | u.active_dev.lcd = viafb_LCD_ON; |
| 506 | u.active_dev.samm = viafb_SAMM_ON; |
| 507 | u.active_dev.primary_dev = viafb_primary_dev; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 508 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 509 | u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method; |
| 510 | u.active_dev.lcd_panel_id = viafb_lcd_panel_id; |
| 511 | u.active_dev.lcd_mode = viafb_lcd_mode; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 512 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 513 | u.active_dev.xres = viafb_hotplug_Xres; |
| 514 | u.active_dev.yres = viafb_hotplug_Yres; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 515 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 516 | u.active_dev.xres1 = viafb_second_xres; |
| 517 | u.active_dev.yres1 = viafb_second_yres; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 518 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 519 | u.active_dev.bpp = viafb_bpp; |
| 520 | u.active_dev.bpp1 = viafb_bpp1; |
| 521 | u.active_dev.refresh = viafb_refresh; |
| 522 | u.active_dev.refresh1 = viafb_refresh1; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 523 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 524 | u.active_dev.epia_dvi = viafb_platform_epia_dvi; |
| 525 | u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge; |
| 526 | u.active_dev.bus_width = viafb_bus_width; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 527 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 528 | if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 529 | return -EFAULT; |
| 530 | break; |
| 531 | |
| 532 | case VIAFB_GET_DRIVER_VERSION: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 533 | u.driver_version.iMajorNum = VERSION_MAJOR; |
| 534 | u.driver_version.iKernelNum = VERSION_KERNEL; |
| 535 | u.driver_version.iOSNum = VERSION_OS; |
| 536 | u.driver_version.iMinorNum = VERSION_MINOR; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 537 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 538 | if (copy_to_user(argp, &u.driver_version, |
| 539 | sizeof(u.driver_version))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 540 | return -EFAULT; |
| 541 | |
| 542 | break; |
| 543 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 544 | case VIAFB_GET_DEVICE_INFO: |
| 545 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 546 | retrieve_device_setting(&u.viafb_setting); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 547 | |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 548 | if (copy_to_user(argp, &u.viafb_setting, |
| 549 | sizeof(u.viafb_setting))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 550 | return -EFAULT; |
| 551 | |
| 552 | break; |
| 553 | |
| 554 | case VIAFB_GET_DEVICE_SUPPORT: |
| 555 | viafb_get_device_support_state(&state_info); |
| 556 | if (put_user(state_info, argp)) |
| 557 | return -EFAULT; |
| 558 | break; |
| 559 | |
| 560 | case VIAFB_GET_DEVICE_CONNECT: |
| 561 | viafb_get_device_connect_state(&state_info); |
| 562 | if (put_user(state_info, argp)) |
| 563 | return -EFAULT; |
| 564 | break; |
| 565 | |
| 566 | case VIAFB_GET_PANEL_SUPPORT_EXPAND: |
| 567 | state_info = |
| 568 | viafb_lcd_get_support_expand_state(info->var.xres, |
| 569 | info->var.yres); |
| 570 | if (put_user(state_info, argp)) |
| 571 | return -EFAULT; |
| 572 | break; |
| 573 | |
| 574 | case VIAFB_GET_DRIVER_NAME: |
| 575 | if (copy_to_user(argp, driver_name, sizeof(driver_name))) |
| 576 | return -EFAULT; |
| 577 | break; |
| 578 | |
| 579 | case VIAFB_SET_GAMMA_LUT: |
Julia Lawall | a51faab | 2010-05-26 14:42:29 -0700 | [diff] [blame] | 580 | viafb_gamma_table = memdup_user(argp, 256 * sizeof(u32)); |
| 581 | if (IS_ERR(viafb_gamma_table)) |
| 582 | return PTR_ERR(viafb_gamma_table); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 583 | viafb_set_gamma_table(viafb_bpp, viafb_gamma_table); |
| 584 | kfree(viafb_gamma_table); |
| 585 | break; |
| 586 | |
| 587 | case VIAFB_GET_GAMMA_LUT: |
| 588 | viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL); |
| 589 | if (!viafb_gamma_table) |
| 590 | return -ENOMEM; |
| 591 | viafb_get_gamma_table(viafb_gamma_table); |
| 592 | if (copy_to_user(argp, viafb_gamma_table, |
Julia Lawall | 0f05058 | 2009-12-17 15:27:09 -0800 | [diff] [blame] | 593 | 256 * sizeof(u32))) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 594 | kfree(viafb_gamma_table); |
| 595 | return -EFAULT; |
| 596 | } |
| 597 | kfree(viafb_gamma_table); |
| 598 | break; |
| 599 | |
| 600 | case VIAFB_GET_GAMMA_SUPPORT_STATE: |
| 601 | viafb_get_gamma_support_state(viafb_bpp, &state_info); |
| 602 | if (put_user(state_info, argp)) |
| 603 | return -EFAULT; |
| 604 | break; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 605 | case VIAFB_SYNC_SURFACE: |
| 606 | DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n"); |
| 607 | break; |
| 608 | case VIAFB_GET_DRIVER_CAPS: |
| 609 | break; |
| 610 | |
| 611 | case VIAFB_GET_PANEL_MAX_SIZE: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 612 | if (copy_from_user(&u.panel_pos_size_para, argp, |
| 613 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 614 | return -EFAULT; |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 615 | u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; |
| 616 | if (copy_to_user(argp, &u.panel_pos_size_para, |
| 617 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 618 | return -EFAULT; |
| 619 | break; |
| 620 | case VIAFB_GET_PANEL_MAX_POSITION: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 621 | if (copy_from_user(&u.panel_pos_size_para, argp, |
| 622 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 623 | return -EFAULT; |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 624 | u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; |
| 625 | if (copy_to_user(argp, &u.panel_pos_size_para, |
| 626 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 627 | return -EFAULT; |
| 628 | break; |
| 629 | |
| 630 | case VIAFB_GET_PANEL_POSITION: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 631 | if (copy_from_user(&u.panel_pos_size_para, argp, |
| 632 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 633 | return -EFAULT; |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 634 | u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; |
| 635 | if (copy_to_user(argp, &u.panel_pos_size_para, |
| 636 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 637 | return -EFAULT; |
| 638 | break; |
| 639 | case VIAFB_GET_PANEL_SIZE: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 640 | if (copy_from_user(&u.panel_pos_size_para, argp, |
| 641 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 642 | return -EFAULT; |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 643 | u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0; |
| 644 | if (copy_to_user(argp, &u.panel_pos_size_para, |
| 645 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 646 | return -EFAULT; |
| 647 | break; |
| 648 | |
| 649 | case VIAFB_SET_PANEL_POSITION: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 650 | if (copy_from_user(&u.panel_pos_size_para, argp, |
| 651 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 652 | return -EFAULT; |
| 653 | break; |
| 654 | case VIAFB_SET_PANEL_SIZE: |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 655 | if (copy_from_user(&u.panel_pos_size_para, argp, |
| 656 | sizeof(u.panel_pos_size_para))) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 657 | return -EFAULT; |
| 658 | break; |
| 659 | |
| 660 | default: |
| 661 | return -EINVAL; |
| 662 | } |
| 663 | |
| 664 | return 0; |
| 665 | } |
| 666 | |
| 667 | static void viafb_fillrect(struct fb_info *info, |
| 668 | const struct fb_fillrect *rect) |
| 669 | { |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 670 | struct viafb_par *viapar = info->par; |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 671 | struct viafb_shared *shared = viapar->shared; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 672 | u32 fg_color; |
| 673 | u8 rop; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 674 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 675 | if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) { |
Hannes Eder | 2899bb0 | 2009-01-06 14:42:32 -0800 | [diff] [blame] | 676 | cfb_fillrect(info, rect); |
| 677 | return; |
| 678 | } |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 679 | |
| 680 | if (!rect->width || !rect->height) |
| 681 | return; |
| 682 | |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 683 | if (info->fix.visual == FB_VISUAL_TRUECOLOR) |
| 684 | fg_color = ((u32 *)info->pseudo_palette)[rect->color]; |
| 685 | else |
| 686 | fg_color = rect->color; |
| 687 | |
| 688 | if (rect->rop == ROP_XOR) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 689 | rop = 0x5A; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 690 | else |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 691 | rop = 0xF0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 692 | |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 693 | DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n"); |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 694 | if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_FILL, |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 695 | rect->width, rect->height, info->var.bits_per_pixel, |
| 696 | viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy, |
| 697 | NULL, 0, 0, 0, 0, fg_color, 0, rop)) |
| 698 | cfb_fillrect(info, rect); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | static void viafb_copyarea(struct fb_info *info, |
| 702 | const struct fb_copyarea *area) |
| 703 | { |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 704 | struct viafb_par *viapar = info->par; |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 705 | struct viafb_shared *shared = viapar->shared; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 706 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 707 | if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) { |
Hannes Eder | 2899bb0 | 2009-01-06 14:42:32 -0800 | [diff] [blame] | 708 | cfb_copyarea(info, area); |
| 709 | return; |
| 710 | } |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 711 | |
| 712 | if (!area->width || !area->height) |
| 713 | return; |
| 714 | |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 715 | DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n"); |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 716 | if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_COLOR, |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 717 | area->width, area->height, info->var.bits_per_pixel, |
| 718 | viapar->vram_addr, info->fix.line_length, area->dx, area->dy, |
| 719 | NULL, viapar->vram_addr, info->fix.line_length, |
| 720 | area->sx, area->sy, 0, 0, 0)) |
| 721 | cfb_copyarea(info, area); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | static void viafb_imageblit(struct fb_info *info, |
| 725 | const struct fb_image *image) |
| 726 | { |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 727 | struct viafb_par *viapar = info->par; |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 728 | struct viafb_shared *shared = viapar->shared; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 729 | u32 fg_color = 0, bg_color = 0; |
| 730 | u8 op; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 731 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 732 | if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt || |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 733 | (image->depth != 1 && image->depth != viapar->depth)) { |
Hannes Eder | 2899bb0 | 2009-01-06 14:42:32 -0800 | [diff] [blame] | 734 | cfb_imageblit(info, image); |
| 735 | return; |
| 736 | } |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 737 | |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 738 | if (image->depth == 1) { |
| 739 | op = VIA_BITBLT_MONO; |
| 740 | if (info->fix.visual == FB_VISUAL_TRUECOLOR) { |
| 741 | fg_color = |
| 742 | ((u32 *)info->pseudo_palette)[image->fg_color]; |
| 743 | bg_color = |
| 744 | ((u32 *)info->pseudo_palette)[image->bg_color]; |
| 745 | } else { |
| 746 | fg_color = image->fg_color; |
| 747 | bg_color = image->bg_color; |
| 748 | } |
| 749 | } else |
| 750 | op = VIA_BITBLT_COLOR; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 751 | |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 752 | DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n"); |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 753 | if (shared->hw_bitblt(shared->vdev->engine_mmio, op, |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 754 | image->width, image->height, info->var.bits_per_pixel, |
| 755 | viapar->vram_addr, info->fix.line_length, image->dx, image->dy, |
| 756 | (u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0)) |
| 757 | cfb_imageblit(info, image); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 758 | } |
| 759 | |
| 760 | static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor) |
| 761 | { |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 762 | struct viafb_par *viapar = info->par; |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 763 | void __iomem *engine = viapar->shared->vdev->engine_mmio; |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 764 | u32 temp, xx, yy, bg_color = 0, fg_color = 0, |
| 765 | chip_name = viapar->shared->chip_info.gfx_chip_name; |
| 766 | int i, j = 0, cur_size = 64; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 767 | |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 768 | if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 769 | return -ENODEV; |
| 770 | |
Florian Tobias Schandinat | 0b94190 | 2010-01-15 17:01:03 -0800 | [diff] [blame] | 771 | /* LCD ouput does not support hw cursors (at least on VN896) */ |
| 772 | if ((chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2) || |
| 773 | viafb_LCD_ON) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 774 | return -ENODEV; |
| 775 | |
| 776 | viafb_show_hw_cursor(info, HW_Cursor_OFF); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 777 | |
| 778 | if (cursor->set & FB_CUR_SETHOT) { |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 779 | temp = (cursor->hot.x << 16) + cursor->hot.y; |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 780 | writel(temp, engine + VIA_REG_CURSOR_ORG); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | if (cursor->set & FB_CUR_SETPOS) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 784 | yy = cursor->image.dy - info->var.yoffset; |
| 785 | xx = cursor->image.dx - info->var.xoffset; |
| 786 | temp = yy & 0xFFFF; |
| 787 | temp |= (xx << 16); |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 788 | writel(temp, engine + VIA_REG_CURSOR_POS); |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | if (cursor->image.width <= 32 && cursor->image.height <= 32) |
| 792 | cur_size = 32; |
| 793 | else if (cursor->image.width <= 64 && cursor->image.height <= 64) |
| 794 | cur_size = 64; |
| 795 | else { |
| 796 | printk(KERN_WARNING "viafb_cursor: The cursor is too large " |
| 797 | "%dx%d", cursor->image.width, cursor->image.height); |
| 798 | return -ENXIO; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | if (cursor->set & FB_CUR_SETSIZE) { |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 802 | temp = readl(engine + VIA_REG_CURSOR_MODE); |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 803 | if (cur_size == 32) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 804 | temp |= 0x2; |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 805 | else |
| 806 | temp &= ~0x2; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 807 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 808 | writel(temp, engine + VIA_REG_CURSOR_MODE); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | if (cursor->set & FB_CUR_SETCMAP) { |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 812 | fg_color = cursor->image.fg_color; |
| 813 | bg_color = cursor->image.bg_color; |
| 814 | if (chip_name == UNICHROME_CX700 || |
Harald Welte | 0306ab1 | 2009-09-22 16:47:35 -0700 | [diff] [blame] | 815 | chip_name == UNICHROME_VX800 || |
Florian Tobias Schandinat | 51f4332 | 2010-10-24 04:02:14 +0000 | [diff] [blame] | 816 | chip_name == UNICHROME_VX855 || |
| 817 | chip_name == UNICHROME_VX900) { |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 818 | fg_color = |
| 819 | ((info->cmap.red[fg_color] & 0xFFC0) << 14) | |
| 820 | ((info->cmap.green[fg_color] & 0xFFC0) << 4) | |
| 821 | ((info->cmap.blue[fg_color] & 0xFFC0) >> 6); |
| 822 | bg_color = |
| 823 | ((info->cmap.red[bg_color] & 0xFFC0) << 14) | |
| 824 | ((info->cmap.green[bg_color] & 0xFFC0) << 4) | |
| 825 | ((info->cmap.blue[bg_color] & 0xFFC0) >> 6); |
| 826 | } else { |
| 827 | fg_color = |
| 828 | ((info->cmap.red[fg_color] & 0xFF00) << 8) | |
| 829 | (info->cmap.green[fg_color] & 0xFF00) | |
| 830 | ((info->cmap.blue[fg_color] & 0xFF00) >> 8); |
| 831 | bg_color = |
| 832 | ((info->cmap.red[bg_color] & 0xFF00) << 8) | |
| 833 | (info->cmap.green[bg_color] & 0xFF00) | |
| 834 | ((info->cmap.blue[bg_color] & 0xFF00) >> 8); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 835 | } |
| 836 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 837 | writel(bg_color, engine + VIA_REG_CURSOR_BG); |
| 838 | writel(fg_color, engine + VIA_REG_CURSOR_FG); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 839 | } |
| 840 | |
| 841 | if (cursor->set & FB_CUR_SETSHAPE) { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 842 | struct { |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 843 | u8 data[CURSOR_SIZE]; |
| 844 | u32 bak[CURSOR_SIZE / 4]; |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 845 | } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC); |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 846 | int size = ((cursor->image.width + 7) >> 3) * |
| 847 | cursor->image.height; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 848 | |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 849 | if (!cr_data) |
| 850 | return -ENOMEM; |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 851 | |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 852 | if (cur_size == 32) { |
| 853 | for (i = 0; i < (CURSOR_SIZE / 4); i++) { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 854 | cr_data->bak[i] = 0x0; |
| 855 | cr_data->bak[i + 1] = 0xFFFFFFFF; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 856 | i += 1; |
| 857 | } |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 858 | } else { |
| 859 | for (i = 0; i < (CURSOR_SIZE / 4); i++) { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 860 | cr_data->bak[i] = 0x0; |
| 861 | cr_data->bak[i + 1] = 0x0; |
| 862 | cr_data->bak[i + 2] = 0xFFFFFFFF; |
| 863 | cr_data->bak[i + 3] = 0xFFFFFFFF; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 864 | i += 3; |
| 865 | } |
| 866 | } |
| 867 | |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 868 | switch (cursor->rop) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 869 | case ROP_XOR: |
| 870 | for (i = 0; i < size; i++) |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 871 | cr_data->data[i] = cursor->mask[i]; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 872 | break; |
| 873 | case ROP_COPY: |
| 874 | |
| 875 | for (i = 0; i < size; i++) |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 876 | cr_data->data[i] = cursor->mask[i]; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 877 | break; |
| 878 | default: |
| 879 | break; |
| 880 | } |
| 881 | |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 882 | if (cur_size == 32) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 883 | for (i = 0; i < size; i++) { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 884 | cr_data->bak[j] = (u32) cr_data->data[i]; |
| 885 | cr_data->bak[j + 1] = ~cr_data->bak[j]; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 886 | j += 2; |
| 887 | } |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 888 | } else { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 889 | for (i = 0; i < size; i++) { |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 890 | cr_data->bak[j] = (u32) cr_data->data[i]; |
| 891 | cr_data->bak[j + 1] = 0x0; |
| 892 | cr_data->bak[j + 2] = ~cr_data->bak[j]; |
| 893 | cr_data->bak[j + 3] = ~cr_data->bak[j + 1]; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 894 | j += 4; |
| 895 | } |
| 896 | } |
| 897 | |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 898 | memcpy_toio(viafbinfo->screen_base + viapar->shared-> |
| 899 | cursor_vram_addr, cr_data->bak, CURSOR_SIZE); |
Bruno Prémont | e687d69 | 2009-01-04 13:11:54 -0800 | [diff] [blame] | 900 | kfree(cr_data); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 901 | } |
| 902 | |
Florian Tobias Schandinat | 5016af53 | 2009-09-22 16:47:28 -0700 | [diff] [blame] | 903 | if (cursor->enable) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 904 | viafb_show_hw_cursor(info, HW_Cursor_ON); |
| 905 | |
| 906 | return 0; |
| 907 | } |
| 908 | |
| 909 | static int viafb_sync(struct fb_info *info) |
| 910 | { |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 911 | if (!(info->flags & FBINFO_HWACCEL_DISABLED)) |
| 912 | viafb_wait_engine_idle(info); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 913 | return 0; |
| 914 | } |
| 915 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 916 | static int get_primary_device(void) |
| 917 | { |
| 918 | int primary_device = 0; |
| 919 | /* Rule: device on iga1 path are the primary device. */ |
| 920 | if (viafb_SAMM_ON) { |
| 921 | if (viafb_CRT_ON) { |
| 922 | if (viaparinfo->crt_setting_info->iga_path == IGA1) { |
| 923 | DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n", |
| 924 | viaparinfo-> |
| 925 | crt_setting_info->iga_path); |
| 926 | primary_device = CRT_Device; |
| 927 | } |
| 928 | } |
| 929 | if (viafb_DVI_ON) { |
| 930 | if (viaparinfo->tmds_setting_info->iga_path == IGA1) { |
| 931 | DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n", |
| 932 | viaparinfo-> |
| 933 | tmds_setting_info->iga_path); |
| 934 | primary_device = DVI_Device; |
| 935 | } |
| 936 | } |
| 937 | if (viafb_LCD_ON) { |
| 938 | if (viaparinfo->lvds_setting_info->iga_path == IGA1) { |
| 939 | DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n", |
| 940 | viaparinfo-> |
| 941 | lvds_setting_info->iga_path); |
| 942 | primary_device = LCD_Device; |
| 943 | } |
| 944 | } |
| 945 | if (viafb_LCD2_ON) { |
| 946 | if (viaparinfo->lvds_setting_info2->iga_path == IGA1) { |
| 947 | DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n", |
| 948 | viaparinfo-> |
| 949 | lvds_setting_info2->iga_path); |
| 950 | primary_device = LCD2_Device; |
| 951 | } |
| 952 | } |
| 953 | } |
| 954 | return primary_device; |
| 955 | } |
| 956 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 957 | static void retrieve_device_setting(struct viafb_ioctl_setting |
| 958 | *setting_info) |
| 959 | { |
| 960 | |
| 961 | /* get device status */ |
| 962 | if (viafb_CRT_ON == 1) |
| 963 | setting_info->device_status = CRT_Device; |
| 964 | if (viafb_DVI_ON == 1) |
| 965 | setting_info->device_status |= DVI_Device; |
| 966 | if (viafb_LCD_ON == 1) |
| 967 | setting_info->device_status |= LCD_Device; |
| 968 | if (viafb_LCD2_ON == 1) |
| 969 | setting_info->device_status |= LCD2_Device; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 970 | |
| 971 | setting_info->samm_status = viafb_SAMM_ON; |
| 972 | setting_info->primary_device = get_primary_device(); |
| 973 | |
| 974 | setting_info->first_dev_bpp = viafb_bpp; |
| 975 | setting_info->second_dev_bpp = viafb_bpp1; |
| 976 | |
| 977 | setting_info->first_dev_refresh = viafb_refresh; |
| 978 | setting_info->second_dev_refresh = viafb_refresh1; |
| 979 | |
| 980 | setting_info->first_dev_hor_res = viafb_hotplug_Xres; |
| 981 | setting_info->first_dev_ver_res = viafb_hotplug_Yres; |
| 982 | setting_info->second_dev_hor_res = viafb_second_xres; |
| 983 | setting_info->second_dev_ver_res = viafb_second_yres; |
| 984 | |
| 985 | /* Get lcd attributes */ |
| 986 | setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method; |
| 987 | setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id; |
| 988 | setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode; |
| 989 | } |
| 990 | |
Florian Tobias Schandinat | f4ab2f7a | 2010-08-09 01:34:27 +0000 | [diff] [blame] | 991 | static int __init parse_active_dev(void) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 992 | { |
| 993 | viafb_CRT_ON = STATE_OFF; |
| 994 | viafb_DVI_ON = STATE_OFF; |
| 995 | viafb_LCD_ON = STATE_OFF; |
| 996 | viafb_LCD2_ON = STATE_OFF; |
| 997 | /* 1. Modify the active status of devices. */ |
| 998 | /* 2. Keep the order of devices, so we can set corresponding |
| 999 | IGA path to devices in SAMM case. */ |
| 1000 | /* Note: The previous of active_dev is primary device, |
| 1001 | and the following is secondary device. */ |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1002 | if (!viafb_active_dev) { |
| 1003 | viafb_CRT_ON = STATE_ON; |
| 1004 | viafb_SAMM_ON = STATE_OFF; |
| 1005 | } else if (!strcmp(viafb_active_dev, "CRT+DVI")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1006 | /* CRT+DVI */ |
| 1007 | viafb_CRT_ON = STATE_ON; |
| 1008 | viafb_DVI_ON = STATE_ON; |
| 1009 | viafb_primary_dev = CRT_Device; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1010 | } else if (!strcmp(viafb_active_dev, "DVI+CRT")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1011 | /* DVI+CRT */ |
| 1012 | viafb_CRT_ON = STATE_ON; |
| 1013 | viafb_DVI_ON = STATE_ON; |
| 1014 | viafb_primary_dev = DVI_Device; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1015 | } else if (!strcmp(viafb_active_dev, "CRT+LCD")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1016 | /* CRT+LCD */ |
| 1017 | viafb_CRT_ON = STATE_ON; |
| 1018 | viafb_LCD_ON = STATE_ON; |
| 1019 | viafb_primary_dev = CRT_Device; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1020 | } else if (!strcmp(viafb_active_dev, "LCD+CRT")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1021 | /* LCD+CRT */ |
| 1022 | viafb_CRT_ON = STATE_ON; |
| 1023 | viafb_LCD_ON = STATE_ON; |
| 1024 | viafb_primary_dev = LCD_Device; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1025 | } else if (!strcmp(viafb_active_dev, "DVI+LCD")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1026 | /* DVI+LCD */ |
| 1027 | viafb_DVI_ON = STATE_ON; |
| 1028 | viafb_LCD_ON = STATE_ON; |
| 1029 | viafb_primary_dev = DVI_Device; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1030 | } else if (!strcmp(viafb_active_dev, "LCD+DVI")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1031 | /* LCD+DVI */ |
| 1032 | viafb_DVI_ON = STATE_ON; |
| 1033 | viafb_LCD_ON = STATE_ON; |
| 1034 | viafb_primary_dev = LCD_Device; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1035 | } else if (!strcmp(viafb_active_dev, "LCD+LCD2")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1036 | viafb_LCD_ON = STATE_ON; |
| 1037 | viafb_LCD2_ON = STATE_ON; |
| 1038 | viafb_primary_dev = LCD_Device; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1039 | } else if (!strcmp(viafb_active_dev, "LCD2+LCD")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1040 | viafb_LCD_ON = STATE_ON; |
| 1041 | viafb_LCD2_ON = STATE_ON; |
| 1042 | viafb_primary_dev = LCD2_Device; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1043 | } else if (!strcmp(viafb_active_dev, "CRT")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1044 | /* CRT only */ |
| 1045 | viafb_CRT_ON = STATE_ON; |
| 1046 | viafb_SAMM_ON = STATE_OFF; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1047 | } else if (!strcmp(viafb_active_dev, "DVI")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1048 | /* DVI only */ |
| 1049 | viafb_DVI_ON = STATE_ON; |
| 1050 | viafb_SAMM_ON = STATE_OFF; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1051 | } else if (!strcmp(viafb_active_dev, "LCD")) { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1052 | /* LCD only */ |
| 1053 | viafb_LCD_ON = STATE_ON; |
| 1054 | viafb_SAMM_ON = STATE_OFF; |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1055 | } else |
| 1056 | return -EINVAL; |
| 1057 | |
| 1058 | return 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1059 | } |
| 1060 | |
Florian Tobias Schandinat | f4ab2f7a | 2010-08-09 01:34:27 +0000 | [diff] [blame] | 1061 | static int __devinit parse_port(char *opt_str, int *output_interface) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1062 | { |
| 1063 | if (!strncmp(opt_str, "DVP0", 4)) |
| 1064 | *output_interface = INTERFACE_DVP0; |
| 1065 | else if (!strncmp(opt_str, "DVP1", 4)) |
| 1066 | *output_interface = INTERFACE_DVP1; |
| 1067 | else if (!strncmp(opt_str, "DFP_HIGHLOW", 11)) |
| 1068 | *output_interface = INTERFACE_DFP; |
| 1069 | else if (!strncmp(opt_str, "DFP_HIGH", 8)) |
| 1070 | *output_interface = INTERFACE_DFP_HIGH; |
| 1071 | else if (!strncmp(opt_str, "DFP_LOW", 7)) |
| 1072 | *output_interface = INTERFACE_DFP_LOW; |
| 1073 | else |
| 1074 | *output_interface = INTERFACE_NONE; |
| 1075 | return 0; |
| 1076 | } |
| 1077 | |
Florian Tobias Schandinat | f4ab2f7a | 2010-08-09 01:34:27 +0000 | [diff] [blame] | 1078 | static void __devinit parse_lcd_port(void) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1079 | { |
| 1080 | parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info. |
| 1081 | output_interface); |
| 1082 | /*Initialize to avoid unexpected behavior */ |
| 1083 | viaparinfo->chip_info->lvds_chip_info2.output_interface = |
| 1084 | INTERFACE_NONE; |
| 1085 | |
| 1086 | DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n", |
| 1087 | viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info. |
| 1088 | output_interface); |
| 1089 | } |
| 1090 | |
Florian Tobias Schandinat | f4ab2f7a | 2010-08-09 01:34:27 +0000 | [diff] [blame] | 1091 | static void __devinit parse_dvi_port(void) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1092 | { |
| 1093 | parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info. |
| 1094 | output_interface); |
| 1095 | |
| 1096 | DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n", |
| 1097 | viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info. |
| 1098 | output_interface); |
| 1099 | } |
| 1100 | |
Florian Tobias Schandinat | 2b78a96 | 2010-04-17 19:44:57 +0000 | [diff] [blame] | 1101 | #ifdef CONFIG_FB_VIA_DIRECT_PROCFS |
| 1102 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1103 | /* |
| 1104 | * The proc filesystem read/write function, a simple proc implement to |
| 1105 | * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1, |
| 1106 | * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], |
| 1107 | * CR9B, SR65, CR97, CR99 |
| 1108 | */ |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1109 | static int viafb_dvp0_proc_show(struct seq_file *m, void *v) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1110 | { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1111 | u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0; |
| 1112 | dvp0_data_dri = |
| 1113 | (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 | |
| 1114 | (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1; |
| 1115 | dvp0_clk_dri = |
| 1116 | (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 | |
| 1117 | (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2; |
| 1118 | dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f; |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1119 | seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri); |
| 1120 | return 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1121 | } |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1122 | |
| 1123 | static int viafb_dvp0_proc_open(struct inode *inode, struct file *file) |
| 1124 | { |
| 1125 | return single_open(file, viafb_dvp0_proc_show, NULL); |
| 1126 | } |
| 1127 | |
| 1128 | static ssize_t viafb_dvp0_proc_write(struct file *file, |
| 1129 | const char __user *buffer, size_t count, loff_t *pos) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1130 | { |
| 1131 | char buf[20], *value, *pbuf; |
| 1132 | u8 reg_val = 0; |
| 1133 | unsigned long length, i; |
| 1134 | if (count < 1) |
| 1135 | return -EINVAL; |
| 1136 | length = count > 20 ? 20 : count; |
| 1137 | if (copy_from_user(&buf[0], buffer, length)) |
| 1138 | return -EFAULT; |
| 1139 | buf[length - 1] = '\0'; /*Ensure end string */ |
| 1140 | pbuf = &buf[0]; |
| 1141 | for (i = 0; i < 3; i++) { |
| 1142 | value = strsep(&pbuf, " "); |
| 1143 | if (value != NULL) { |
| 1144 | strict_strtoul(value, 0, (unsigned long *)®_val); |
| 1145 | DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i, |
| 1146 | reg_val); |
| 1147 | switch (i) { |
| 1148 | case 0: |
| 1149 | viafb_write_reg_mask(CR96, VIACR, |
| 1150 | reg_val, 0x0f); |
| 1151 | break; |
| 1152 | case 1: |
| 1153 | viafb_write_reg_mask(SR2A, VIASR, |
| 1154 | reg_val << 4, BIT5); |
| 1155 | viafb_write_reg_mask(SR1B, VIASR, |
| 1156 | reg_val << 1, BIT1); |
| 1157 | break; |
| 1158 | case 2: |
| 1159 | viafb_write_reg_mask(SR2A, VIASR, |
| 1160 | reg_val << 3, BIT4); |
| 1161 | viafb_write_reg_mask(SR1E, VIASR, |
| 1162 | reg_val << 2, BIT2); |
| 1163 | break; |
| 1164 | default: |
| 1165 | break; |
| 1166 | } |
| 1167 | } else { |
| 1168 | break; |
| 1169 | } |
| 1170 | } |
| 1171 | return count; |
| 1172 | } |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1173 | |
| 1174 | static const struct file_operations viafb_dvp0_proc_fops = { |
| 1175 | .owner = THIS_MODULE, |
| 1176 | .open = viafb_dvp0_proc_open, |
| 1177 | .read = seq_read, |
| 1178 | .llseek = seq_lseek, |
| 1179 | .release = single_release, |
| 1180 | .write = viafb_dvp0_proc_write, |
| 1181 | }; |
| 1182 | |
| 1183 | static int viafb_dvp1_proc_show(struct seq_file *m, void *v) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1184 | { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1185 | u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0; |
| 1186 | dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f; |
| 1187 | dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2; |
| 1188 | dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03; |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1189 | seq_printf(m, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri); |
| 1190 | return 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1191 | } |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1192 | |
| 1193 | static int viafb_dvp1_proc_open(struct inode *inode, struct file *file) |
| 1194 | { |
| 1195 | return single_open(file, viafb_dvp1_proc_show, NULL); |
| 1196 | } |
| 1197 | |
| 1198 | static ssize_t viafb_dvp1_proc_write(struct file *file, |
| 1199 | const char __user *buffer, size_t count, loff_t *pos) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1200 | { |
| 1201 | char buf[20], *value, *pbuf; |
| 1202 | u8 reg_val = 0; |
| 1203 | unsigned long length, i; |
| 1204 | if (count < 1) |
| 1205 | return -EINVAL; |
| 1206 | length = count > 20 ? 20 : count; |
| 1207 | if (copy_from_user(&buf[0], buffer, length)) |
| 1208 | return -EFAULT; |
| 1209 | buf[length - 1] = '\0'; /*Ensure end string */ |
| 1210 | pbuf = &buf[0]; |
| 1211 | for (i = 0; i < 3; i++) { |
| 1212 | value = strsep(&pbuf, " "); |
| 1213 | if (value != NULL) { |
| 1214 | strict_strtoul(value, 0, (unsigned long *)®_val); |
| 1215 | switch (i) { |
| 1216 | case 0: |
| 1217 | viafb_write_reg_mask(CR9B, VIACR, |
| 1218 | reg_val, 0x0f); |
| 1219 | break; |
| 1220 | case 1: |
| 1221 | viafb_write_reg_mask(SR65, VIASR, |
| 1222 | reg_val << 2, 0x0c); |
| 1223 | break; |
| 1224 | case 2: |
| 1225 | viafb_write_reg_mask(SR65, VIASR, |
| 1226 | reg_val, 0x03); |
| 1227 | break; |
| 1228 | default: |
| 1229 | break; |
| 1230 | } |
| 1231 | } else { |
| 1232 | break; |
| 1233 | } |
| 1234 | } |
| 1235 | return count; |
| 1236 | } |
| 1237 | |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1238 | static const struct file_operations viafb_dvp1_proc_fops = { |
| 1239 | .owner = THIS_MODULE, |
| 1240 | .open = viafb_dvp1_proc_open, |
| 1241 | .read = seq_read, |
| 1242 | .llseek = seq_lseek, |
| 1243 | .release = single_release, |
| 1244 | .write = viafb_dvp1_proc_write, |
| 1245 | }; |
| 1246 | |
| 1247 | static int viafb_dfph_proc_show(struct seq_file *m, void *v) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1248 | { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1249 | u8 dfp_high = 0; |
| 1250 | dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f; |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1251 | seq_printf(m, "%x\n", dfp_high); |
| 1252 | return 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1253 | } |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1254 | |
| 1255 | static int viafb_dfph_proc_open(struct inode *inode, struct file *file) |
| 1256 | { |
| 1257 | return single_open(file, viafb_dfph_proc_show, NULL); |
| 1258 | } |
| 1259 | |
| 1260 | static ssize_t viafb_dfph_proc_write(struct file *file, |
| 1261 | const char __user *buffer, size_t count, loff_t *pos) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1262 | { |
| 1263 | char buf[20]; |
| 1264 | u8 reg_val = 0; |
| 1265 | unsigned long length; |
| 1266 | if (count < 1) |
| 1267 | return -EINVAL; |
| 1268 | length = count > 20 ? 20 : count; |
| 1269 | if (copy_from_user(&buf[0], buffer, length)) |
| 1270 | return -EFAULT; |
| 1271 | buf[length - 1] = '\0'; /*Ensure end string */ |
| 1272 | strict_strtoul(&buf[0], 0, (unsigned long *)®_val); |
| 1273 | viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f); |
| 1274 | return count; |
| 1275 | } |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1276 | |
| 1277 | static const struct file_operations viafb_dfph_proc_fops = { |
| 1278 | .owner = THIS_MODULE, |
| 1279 | .open = viafb_dfph_proc_open, |
| 1280 | .read = seq_read, |
| 1281 | .llseek = seq_lseek, |
| 1282 | .release = single_release, |
| 1283 | .write = viafb_dfph_proc_write, |
| 1284 | }; |
| 1285 | |
| 1286 | static int viafb_dfpl_proc_show(struct seq_file *m, void *v) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1287 | { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1288 | u8 dfp_low = 0; |
| 1289 | dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f; |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1290 | seq_printf(m, "%x\n", dfp_low); |
| 1291 | return 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1292 | } |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1293 | |
| 1294 | static int viafb_dfpl_proc_open(struct inode *inode, struct file *file) |
| 1295 | { |
| 1296 | return single_open(file, viafb_dfpl_proc_show, NULL); |
| 1297 | } |
| 1298 | |
| 1299 | static ssize_t viafb_dfpl_proc_write(struct file *file, |
| 1300 | const char __user *buffer, size_t count, loff_t *pos) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1301 | { |
| 1302 | char buf[20]; |
| 1303 | u8 reg_val = 0; |
| 1304 | unsigned long length; |
| 1305 | if (count < 1) |
| 1306 | return -EINVAL; |
| 1307 | length = count > 20 ? 20 : count; |
| 1308 | if (copy_from_user(&buf[0], buffer, length)) |
| 1309 | return -EFAULT; |
| 1310 | buf[length - 1] = '\0'; /*Ensure end string */ |
| 1311 | strict_strtoul(&buf[0], 0, (unsigned long *)®_val); |
| 1312 | viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f); |
| 1313 | return count; |
| 1314 | } |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1315 | |
| 1316 | static const struct file_operations viafb_dfpl_proc_fops = { |
| 1317 | .owner = THIS_MODULE, |
| 1318 | .open = viafb_dfpl_proc_open, |
| 1319 | .read = seq_read, |
| 1320 | .llseek = seq_lseek, |
| 1321 | .release = single_release, |
| 1322 | .write = viafb_dfpl_proc_write, |
| 1323 | }; |
| 1324 | |
| 1325 | static int viafb_vt1636_proc_show(struct seq_file *m, void *v) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1326 | { |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1327 | u8 vt1636_08 = 0, vt1636_09 = 0; |
| 1328 | switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { |
| 1329 | case VT1636_LVDS: |
| 1330 | vt1636_08 = |
| 1331 | viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info, |
| 1332 | &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f; |
| 1333 | vt1636_09 = |
| 1334 | viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info, |
| 1335 | &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f; |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1336 | seq_printf(m, "%x %x\n", vt1636_08, vt1636_09); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1337 | break; |
| 1338 | default: |
| 1339 | break; |
| 1340 | } |
| 1341 | switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { |
| 1342 | case VT1636_LVDS: |
| 1343 | vt1636_08 = |
| 1344 | viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2, |
| 1345 | &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f; |
| 1346 | vt1636_09 = |
| 1347 | viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2, |
| 1348 | &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f; |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1349 | seq_printf(m, " %x %x\n", vt1636_08, vt1636_09); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1350 | break; |
| 1351 | default: |
| 1352 | break; |
| 1353 | } |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1354 | return 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1355 | } |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1356 | |
| 1357 | static int viafb_vt1636_proc_open(struct inode *inode, struct file *file) |
| 1358 | { |
| 1359 | return single_open(file, viafb_vt1636_proc_show, NULL); |
| 1360 | } |
| 1361 | |
| 1362 | static ssize_t viafb_vt1636_proc_write(struct file *file, |
| 1363 | const char __user *buffer, size_t count, loff_t *pos) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1364 | { |
| 1365 | char buf[30], *value, *pbuf; |
| 1366 | struct IODATA reg_val; |
| 1367 | unsigned long length, i; |
| 1368 | if (count < 1) |
| 1369 | return -EINVAL; |
| 1370 | length = count > 30 ? 30 : count; |
| 1371 | if (copy_from_user(&buf[0], buffer, length)) |
| 1372 | return -EFAULT; |
| 1373 | buf[length - 1] = '\0'; /*Ensure end string */ |
| 1374 | pbuf = &buf[0]; |
| 1375 | switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { |
| 1376 | case VT1636_LVDS: |
| 1377 | for (i = 0; i < 2; i++) { |
| 1378 | value = strsep(&pbuf, " "); |
| 1379 | if (value != NULL) { |
| 1380 | strict_strtoul(value, 0, |
| 1381 | (unsigned long *)®_val.Data); |
| 1382 | switch (i) { |
| 1383 | case 0: |
| 1384 | reg_val.Index = 0x08; |
| 1385 | reg_val.Mask = 0x0f; |
| 1386 | viafb_gpio_i2c_write_mask_lvds |
| 1387 | (viaparinfo->lvds_setting_info, |
| 1388 | &viaparinfo-> |
| 1389 | chip_info->lvds_chip_info, |
| 1390 | reg_val); |
| 1391 | break; |
| 1392 | case 1: |
| 1393 | reg_val.Index = 0x09; |
| 1394 | reg_val.Mask = 0x1f; |
| 1395 | viafb_gpio_i2c_write_mask_lvds |
| 1396 | (viaparinfo->lvds_setting_info, |
| 1397 | &viaparinfo-> |
| 1398 | chip_info->lvds_chip_info, |
| 1399 | reg_val); |
| 1400 | break; |
| 1401 | default: |
| 1402 | break; |
| 1403 | } |
| 1404 | } else { |
| 1405 | break; |
| 1406 | } |
| 1407 | } |
| 1408 | break; |
| 1409 | default: |
| 1410 | break; |
| 1411 | } |
| 1412 | switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { |
| 1413 | case VT1636_LVDS: |
| 1414 | for (i = 0; i < 2; i++) { |
| 1415 | value = strsep(&pbuf, " "); |
| 1416 | if (value != NULL) { |
| 1417 | strict_strtoul(value, 0, |
| 1418 | (unsigned long *)®_val.Data); |
| 1419 | switch (i) { |
| 1420 | case 0: |
| 1421 | reg_val.Index = 0x08; |
| 1422 | reg_val.Mask = 0x0f; |
| 1423 | viafb_gpio_i2c_write_mask_lvds |
| 1424 | (viaparinfo->lvds_setting_info2, |
| 1425 | &viaparinfo-> |
| 1426 | chip_info->lvds_chip_info2, |
| 1427 | reg_val); |
| 1428 | break; |
| 1429 | case 1: |
| 1430 | reg_val.Index = 0x09; |
| 1431 | reg_val.Mask = 0x1f; |
| 1432 | viafb_gpio_i2c_write_mask_lvds |
| 1433 | (viaparinfo->lvds_setting_info2, |
| 1434 | &viaparinfo-> |
| 1435 | chip_info->lvds_chip_info2, |
| 1436 | reg_val); |
| 1437 | break; |
| 1438 | default: |
| 1439 | break; |
| 1440 | } |
| 1441 | } else { |
| 1442 | break; |
| 1443 | } |
| 1444 | } |
| 1445 | break; |
| 1446 | default: |
| 1447 | break; |
| 1448 | } |
| 1449 | return count; |
| 1450 | } |
| 1451 | |
Alexey Dobriyan | afbd3c1 | 2009-09-22 16:47:27 -0700 | [diff] [blame] | 1452 | static const struct file_operations viafb_vt1636_proc_fops = { |
| 1453 | .owner = THIS_MODULE, |
| 1454 | .open = viafb_vt1636_proc_open, |
| 1455 | .read = seq_read, |
| 1456 | .llseek = seq_lseek, |
| 1457 | .release = single_release, |
| 1458 | .write = viafb_vt1636_proc_write, |
| 1459 | }; |
| 1460 | |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1461 | #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */ |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1462 | |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 1463 | static int viafb_sup_odev_proc_show(struct seq_file *m, void *v) |
| 1464 | { |
| 1465 | via_odev_to_seq(m, supported_odev_map[ |
| 1466 | viaparinfo->shared->chip_info.gfx_chip_name]); |
| 1467 | return 0; |
| 1468 | } |
| 1469 | |
| 1470 | static int viafb_sup_odev_proc_open(struct inode *inode, struct file *file) |
| 1471 | { |
| 1472 | return single_open(file, viafb_sup_odev_proc_show, NULL); |
| 1473 | } |
| 1474 | |
| 1475 | static const struct file_operations viafb_sup_odev_proc_fops = { |
| 1476 | .owner = THIS_MODULE, |
| 1477 | .open = viafb_sup_odev_proc_open, |
| 1478 | .read = seq_read, |
| 1479 | .llseek = seq_lseek, |
| 1480 | .release = single_release, |
| 1481 | }; |
| 1482 | |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1483 | static ssize_t odev_update(const char __user *buffer, size_t count, u32 *odev) |
| 1484 | { |
| 1485 | char buf[64], *ptr = buf; |
| 1486 | u32 devices; |
| 1487 | bool add, sub; |
| 1488 | |
| 1489 | if (count < 1 || count > 63) |
| 1490 | return -EINVAL; |
| 1491 | if (copy_from_user(&buf[0], buffer, count)) |
| 1492 | return -EFAULT; |
| 1493 | buf[count] = '\0'; |
| 1494 | add = buf[0] == '+'; |
| 1495 | sub = buf[0] == '-'; |
| 1496 | if (add || sub) |
| 1497 | ptr++; |
| 1498 | devices = via_parse_odev(ptr, &ptr); |
| 1499 | if (*ptr == '\n') |
| 1500 | ptr++; |
| 1501 | if (*ptr != 0) |
| 1502 | return -EINVAL; |
| 1503 | if (add) |
| 1504 | *odev |= devices; |
| 1505 | else if (sub) |
| 1506 | *odev &= ~devices; |
| 1507 | else |
| 1508 | *odev = devices; |
| 1509 | return count; |
| 1510 | } |
| 1511 | |
| 1512 | static int viafb_iga1_odev_proc_show(struct seq_file *m, void *v) |
| 1513 | { |
| 1514 | via_odev_to_seq(m, viaparinfo->shared->iga1_devices); |
| 1515 | return 0; |
| 1516 | } |
| 1517 | |
| 1518 | static int viafb_iga1_odev_proc_open(struct inode *inode, struct file *file) |
| 1519 | { |
| 1520 | return single_open(file, viafb_iga1_odev_proc_show, NULL); |
| 1521 | } |
| 1522 | |
| 1523 | static ssize_t viafb_iga1_odev_proc_write(struct file *file, |
| 1524 | const char __user *buffer, size_t count, loff_t *pos) |
| 1525 | { |
| 1526 | u32 dev_on, dev_off, dev_old, dev_new; |
| 1527 | ssize_t res; |
| 1528 | |
| 1529 | dev_old = dev_new = viaparinfo->shared->iga1_devices; |
| 1530 | res = odev_update(buffer, count, &dev_new); |
| 1531 | if (res != count) |
| 1532 | return res; |
| 1533 | dev_off = dev_old & ~dev_new; |
| 1534 | dev_on = dev_new & ~dev_old; |
| 1535 | viaparinfo->shared->iga1_devices = dev_new; |
| 1536 | viaparinfo->shared->iga2_devices &= ~dev_new; |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 1537 | via_set_state(dev_off, VIA_STATE_OFF); |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1538 | via_set_source(dev_new, IGA1); |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 1539 | via_set_state(dev_on, VIA_STATE_ON); |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1540 | return res; |
| 1541 | } |
| 1542 | |
| 1543 | static const struct file_operations viafb_iga1_odev_proc_fops = { |
| 1544 | .owner = THIS_MODULE, |
| 1545 | .open = viafb_iga1_odev_proc_open, |
| 1546 | .read = seq_read, |
| 1547 | .llseek = seq_lseek, |
| 1548 | .release = single_release, |
| 1549 | .write = viafb_iga1_odev_proc_write, |
| 1550 | }; |
| 1551 | |
| 1552 | static int viafb_iga2_odev_proc_show(struct seq_file *m, void *v) |
| 1553 | { |
| 1554 | via_odev_to_seq(m, viaparinfo->shared->iga2_devices); |
| 1555 | return 0; |
| 1556 | } |
| 1557 | |
| 1558 | static int viafb_iga2_odev_proc_open(struct inode *inode, struct file *file) |
| 1559 | { |
| 1560 | return single_open(file, viafb_iga2_odev_proc_show, NULL); |
| 1561 | } |
| 1562 | |
| 1563 | static ssize_t viafb_iga2_odev_proc_write(struct file *file, |
| 1564 | const char __user *buffer, size_t count, loff_t *pos) |
| 1565 | { |
| 1566 | u32 dev_on, dev_off, dev_old, dev_new; |
| 1567 | ssize_t res; |
| 1568 | |
| 1569 | dev_old = dev_new = viaparinfo->shared->iga2_devices; |
| 1570 | res = odev_update(buffer, count, &dev_new); |
| 1571 | if (res != count) |
| 1572 | return res; |
| 1573 | dev_off = dev_old & ~dev_new; |
| 1574 | dev_on = dev_new & ~dev_old; |
| 1575 | viaparinfo->shared->iga2_devices = dev_new; |
| 1576 | viaparinfo->shared->iga1_devices &= ~dev_new; |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 1577 | via_set_state(dev_off, VIA_STATE_OFF); |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1578 | via_set_source(dev_new, IGA2); |
Florian Tobias Schandinat | 6f9422d | 2010-09-07 14:28:26 +0000 | [diff] [blame] | 1579 | via_set_state(dev_on, VIA_STATE_ON); |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1580 | return res; |
| 1581 | } |
| 1582 | |
| 1583 | static const struct file_operations viafb_iga2_odev_proc_fops = { |
| 1584 | .owner = THIS_MODULE, |
| 1585 | .open = viafb_iga2_odev_proc_open, |
| 1586 | .read = seq_read, |
| 1587 | .llseek = seq_lseek, |
| 1588 | .release = single_release, |
| 1589 | .write = viafb_iga2_odev_proc_write, |
| 1590 | }; |
| 1591 | |
| 1592 | #define IS_VT1636(lvds_chip) ((lvds_chip).lvds_chip_name == VT1636_LVDS) |
| 1593 | static void viafb_init_proc(struct viafb_shared *shared) |
| 1594 | { |
| 1595 | struct proc_dir_entry *iga1_entry, *iga2_entry, |
| 1596 | *viafb_entry = proc_mkdir("viafb", NULL); |
| 1597 | |
| 1598 | shared->proc_entry = viafb_entry; |
| 1599 | if (viafb_entry) { |
| 1600 | #ifdef CONFIG_FB_VIA_DIRECT_PROCFS |
| 1601 | proc_create("dvp0", 0, viafb_entry, &viafb_dvp0_proc_fops); |
| 1602 | proc_create("dvp1", 0, viafb_entry, &viafb_dvp1_proc_fops); |
| 1603 | proc_create("dfph", 0, viafb_entry, &viafb_dfph_proc_fops); |
| 1604 | proc_create("dfpl", 0, viafb_entry, &viafb_dfpl_proc_fops); |
| 1605 | if (IS_VT1636(shared->chip_info.lvds_chip_info) |
| 1606 | || IS_VT1636(shared->chip_info.lvds_chip_info2)) |
| 1607 | proc_create("vt1636", 0, viafb_entry, |
| 1608 | &viafb_vt1636_proc_fops); |
| 1609 | #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */ |
| 1610 | |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 1611 | proc_create("supported_output_devices", 0, viafb_entry, |
| 1612 | &viafb_sup_odev_proc_fops); |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1613 | iga1_entry = proc_mkdir("iga1", viafb_entry); |
| 1614 | shared->iga1_proc_entry = iga1_entry; |
| 1615 | proc_create("output_devices", 0, iga1_entry, |
| 1616 | &viafb_iga1_odev_proc_fops); |
| 1617 | iga2_entry = proc_mkdir("iga2", viafb_entry); |
| 1618 | shared->iga2_proc_entry = iga2_entry; |
| 1619 | proc_create("output_devices", 0, iga2_entry, |
| 1620 | &viafb_iga2_odev_proc_fops); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1621 | } |
| 1622 | } |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1623 | static void viafb_remove_proc(struct viafb_shared *shared) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1624 | { |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1625 | struct proc_dir_entry *viafb_entry = shared->proc_entry, |
| 1626 | *iga1_entry = shared->iga1_proc_entry, |
| 1627 | *iga2_entry = shared->iga2_proc_entry; |
Florian Tobias Schandinat | 2fed547 | 2010-04-17 19:44:56 +0000 | [diff] [blame] | 1628 | |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1629 | if (!viafb_entry) |
| 1630 | return; |
| 1631 | |
| 1632 | remove_proc_entry("output_devices", iga2_entry); |
| 1633 | remove_proc_entry("iga2", viafb_entry); |
| 1634 | remove_proc_entry("output_devices", iga1_entry); |
| 1635 | remove_proc_entry("iga1", viafb_entry); |
Florian Tobias Schandinat | dd7a0b0 | 2010-09-19 04:20:55 +0000 | [diff] [blame] | 1636 | remove_proc_entry("supported_output_devices", viafb_entry); |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1637 | |
| 1638 | #ifdef CONFIG_FB_VIA_DIRECT_PROCFS |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1639 | remove_proc_entry("dvp0", viafb_entry);/* parent dir */ |
| 1640 | remove_proc_entry("dvp1", viafb_entry); |
| 1641 | remove_proc_entry("dfph", viafb_entry); |
| 1642 | remove_proc_entry("dfpl", viafb_entry); |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1643 | if (IS_VT1636(shared->chip_info.lvds_chip_info) |
| 1644 | || IS_VT1636(shared->chip_info.lvds_chip_info2)) |
Florian Tobias Schandinat | 2fed547 | 2010-04-17 19:44:56 +0000 | [diff] [blame] | 1645 | remove_proc_entry("vt1636", viafb_entry); |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1646 | #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */ |
Florian Tobias Schandinat | 2fed547 | 2010-04-17 19:44:56 +0000 | [diff] [blame] | 1647 | |
Bruno Prémont | c267fd7 | 2008-11-19 15:36:23 -0800 | [diff] [blame] | 1648 | remove_proc_entry("viafb", NULL); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1649 | } |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1650 | #undef IS_VT1636 |
Florian Tobias Schandinat | 2b78a96 | 2010-04-17 19:44:57 +0000 | [diff] [blame] | 1651 | |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1652 | static int parse_mode(const char *str, u32 *xres, u32 *yres) |
Florian Tobias Schandinat | 5ff32f6 | 2009-09-22 16:47:34 -0700 | [diff] [blame] | 1653 | { |
| 1654 | char *ptr; |
| 1655 | |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1656 | if (!str) { |
| 1657 | *xres = 640; |
| 1658 | *yres = 480; |
| 1659 | return 0; |
| 1660 | } |
| 1661 | |
Florian Tobias Schandinat | 5ff32f6 | 2009-09-22 16:47:34 -0700 | [diff] [blame] | 1662 | *xres = simple_strtoul(str, &ptr, 10); |
| 1663 | if (ptr[0] != 'x') |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1664 | return -EINVAL; |
Florian Tobias Schandinat | 5ff32f6 | 2009-09-22 16:47:34 -0700 | [diff] [blame] | 1665 | |
| 1666 | *yres = simple_strtoul(&ptr[1], &ptr, 10); |
| 1667 | if (ptr[0]) |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1668 | return -EINVAL; |
Florian Tobias Schandinat | 5ff32f6 | 2009-09-22 16:47:34 -0700 | [diff] [blame] | 1669 | |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 1670 | return 0; |
Florian Tobias Schandinat | 5ff32f6 | 2009-09-22 16:47:34 -0700 | [diff] [blame] | 1671 | } |
| 1672 | |
Jonathan Corbet | f045f77 | 2009-12-01 20:29:39 -0700 | [diff] [blame] | 1673 | |
Deepak Saxena | 3fd9b6c | 2010-04-08 11:15:41 -0600 | [diff] [blame] | 1674 | #ifdef CONFIG_PM |
Daniel Drake | 751305d | 2010-10-28 18:23:01 +0100 | [diff] [blame^] | 1675 | static int viafb_suspend(void *unused) |
Deepak Saxena | 3fd9b6c | 2010-04-08 11:15:41 -0600 | [diff] [blame] | 1676 | { |
Daniel Drake | 751305d | 2010-10-28 18:23:01 +0100 | [diff] [blame^] | 1677 | acquire_console_sem(); |
| 1678 | fb_set_suspend(viafbinfo, 1); |
| 1679 | viafb_sync(viafbinfo); |
| 1680 | release_console_sem(); |
Deepak Saxena | 3fd9b6c | 2010-04-08 11:15:41 -0600 | [diff] [blame] | 1681 | |
| 1682 | return 0; |
| 1683 | } |
| 1684 | |
Daniel Drake | 751305d | 2010-10-28 18:23:01 +0100 | [diff] [blame^] | 1685 | static int viafb_resume(void *unused) |
Deepak Saxena | 3fd9b6c | 2010-04-08 11:15:41 -0600 | [diff] [blame] | 1686 | { |
| 1687 | acquire_console_sem(); |
Florian Tobias Schandinat | adac8d6 | 2010-04-26 17:31:03 +0000 | [diff] [blame] | 1688 | if (viaparinfo->shared->vdev->engine_mmio) |
| 1689 | viafb_reset_engine(viaparinfo); |
Florian Tobias Schandinat | b75f2c0 | 2010-04-26 16:37:53 +0000 | [diff] [blame] | 1690 | viafb_set_par(viafbinfo); |
| 1691 | if (viafb_dual_fb) |
| 1692 | viafb_set_par(viafbinfo1); |
Deepak Saxena | 3fd9b6c | 2010-04-08 11:15:41 -0600 | [diff] [blame] | 1693 | fb_set_suspend(viafbinfo, 0); |
| 1694 | |
Deepak Saxena | 3fd9b6c | 2010-04-08 11:15:41 -0600 | [diff] [blame] | 1695 | release_console_sem(); |
| 1696 | return 0; |
| 1697 | } |
| 1698 | |
Daniel Drake | 751305d | 2010-10-28 18:23:01 +0100 | [diff] [blame^] | 1699 | static struct viafb_pm_hooks viafb_fb_pm_hooks = { |
| 1700 | .suspend = viafb_suspend, |
| 1701 | .resume = viafb_resume |
| 1702 | }; |
| 1703 | |
Deepak Saxena | 3fd9b6c | 2010-04-08 11:15:41 -0600 | [diff] [blame] | 1704 | #endif |
| 1705 | |
| 1706 | |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 1707 | int __devinit via_fb_pci_probe(struct viafb_dev *vdev) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1708 | { |
Florian Tobias Schandinat | 5ff32f6 | 2009-09-22 16:47:34 -0700 | [diff] [blame] | 1709 | u32 default_xres, default_yres; |
Florian Tobias Schandinat | dd73d68 | 2010-03-10 15:21:28 -0800 | [diff] [blame] | 1710 | struct VideoModeTable *vmode_entry; |
Florian Tobias Schandinat | dba77f8 | 2010-03-10 15:21:37 -0800 | [diff] [blame] | 1711 | struct fb_var_screeninfo default_var; |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 1712 | int rc; |
Florian Tobias Schandinat | c4df548 | 2009-09-22 16:47:24 -0700 | [diff] [blame] | 1713 | u32 viafb_par_length; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1714 | |
| 1715 | DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n"); |
Florian Tobias Schandinat | dba77f8 | 2010-03-10 15:21:37 -0800 | [diff] [blame] | 1716 | memset(&default_var, 0, sizeof(default_var)); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1717 | viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1718 | |
| 1719 | /* Allocate fb_info and ***_par here, also including some other needed |
| 1720 | * variables |
| 1721 | */ |
Florian Tobias Schandinat | c4df548 | 2009-09-22 16:47:24 -0700 | [diff] [blame] | 1722 | viafbinfo = framebuffer_alloc(viafb_par_length + |
Harald Welte | db8df7b | 2009-09-22 16:47:38 -0700 | [diff] [blame] | 1723 | ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8), |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 1724 | &vdev->pdev->dev); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1725 | if (!viafbinfo) { |
| 1726 | printk(KERN_ERR"Could not allocate memory for viafb_info.\n"); |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 1727 | return -ENOMEM; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1728 | } |
| 1729 | |
| 1730 | viaparinfo = (struct viafb_par *)viafbinfo->par; |
Florian Tobias Schandinat | c4df548 | 2009-09-22 16:47:24 -0700 | [diff] [blame] | 1731 | viaparinfo->shared = viafbinfo->par + viafb_par_length; |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 1732 | viaparinfo->shared->vdev = vdev; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 1733 | viaparinfo->vram_addr = 0; |
Florian Tobias Schandinat | c4df548 | 2009-09-22 16:47:24 -0700 | [diff] [blame] | 1734 | viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info; |
| 1735 | viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info; |
| 1736 | viaparinfo->lvds_setting_info2 = |
| 1737 | &viaparinfo->shared->lvds_setting_info2; |
| 1738 | viaparinfo->crt_setting_info = &viaparinfo->shared->crt_setting_info; |
| 1739 | viaparinfo->chip_info = &viaparinfo->shared->chip_info; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1740 | |
| 1741 | if (viafb_dual_fb) |
| 1742 | viafb_SAMM_ON = 1; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1743 | parse_lcd_port(); |
| 1744 | parse_dvi_port(); |
| 1745 | |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 1746 | viafb_init_chip_info(vdev->chip_type); |
| 1747 | /* |
| 1748 | * The framebuffer will have been successfully mapped by |
| 1749 | * the core (or we'd not be here), but we still need to |
| 1750 | * set up our own accounting. |
| 1751 | */ |
| 1752 | viaparinfo->fbmem = vdev->fbmem_start; |
| 1753 | viaparinfo->memsize = vdev->fbmem_len; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1754 | viaparinfo->fbmem_free = viaparinfo->memsize; |
| 1755 | viaparinfo->fbmem_used = 0; |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 1756 | viafbinfo->screen_base = vdev->fbmem; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1757 | |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 1758 | viafbinfo->fix.mmio_start = vdev->engine_start; |
| 1759 | viafbinfo->fix.mmio_len = vdev->engine_len; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1760 | viafbinfo->node = 0; |
| 1761 | viafbinfo->fbops = &viafb_ops; |
| 1762 | viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; |
| 1763 | |
| 1764 | viafbinfo->pseudo_palette = pseudo_pal; |
Florian Tobias Schandinat | adac8d6 | 2010-04-26 17:31:03 +0000 | [diff] [blame] | 1765 | if (viafb_accel && !viafb_setup_engine(viafbinfo)) { |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 1766 | viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA | |
| 1767 | FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT; |
| 1768 | default_var.accel_flags = FB_ACCELF_TEXT; |
| 1769 | } else { |
| 1770 | viafbinfo->flags |= FBINFO_HWACCEL_DISABLED; |
| 1771 | default_var.accel_flags = 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1772 | } |
| 1773 | |
| 1774 | if (viafb_second_size && (viafb_second_size < 8)) { |
| 1775 | viafb_second_offset = viaparinfo->fbmem_free - |
| 1776 | viafb_second_size * 1024 * 1024; |
| 1777 | } else { |
| 1778 | viafb_second_size = 8; |
| 1779 | viafb_second_offset = viaparinfo->fbmem_free - |
| 1780 | viafb_second_size * 1024 * 1024; |
| 1781 | } |
| 1782 | |
Florian Tobias Schandinat | 5ff32f6 | 2009-09-22 16:47:34 -0700 | [diff] [blame] | 1783 | parse_mode(viafb_mode, &default_xres, &default_yres); |
Florian Tobias Schandinat | dd73d68 | 2010-03-10 15:21:28 -0800 | [diff] [blame] | 1784 | vmode_entry = viafb_get_mode(default_xres, default_yres); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1785 | if (viafb_SAMM_ON == 1) { |
Florian Tobias Schandinat | 5ff32f6 | 2009-09-22 16:47:34 -0700 | [diff] [blame] | 1786 | parse_mode(viafb_mode1, &viafb_second_xres, |
| 1787 | &viafb_second_yres); |
| 1788 | |
Florian Tobias Schandinat | cd58995 | 2010-07-13 19:44:05 +0000 | [diff] [blame] | 1789 | viafb_second_virtual_xres = viafb_second_xres; |
| 1790 | viafb_second_virtual_yres = viafb_second_yres; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1791 | } |
| 1792 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1793 | default_var.xres = default_xres; |
| 1794 | default_var.yres = default_yres; |
Florian Tobias Schandinat | cd58995 | 2010-07-13 19:44:05 +0000 | [diff] [blame] | 1795 | default_var.xres_virtual = default_xres; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1796 | default_var.yres_virtual = default_yres; |
| 1797 | default_var.bits_per_pixel = viafb_bpp; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1798 | default_var.pixclock = |
| 1799 | viafb_get_pixclock(default_xres, default_yres, viafb_refresh); |
| 1800 | default_var.left_margin = (default_xres >> 3) & 0xf8; |
| 1801 | default_var.right_margin = 32; |
| 1802 | default_var.upper_margin = 16; |
| 1803 | default_var.lower_margin = 4; |
| 1804 | default_var.hsync_len = default_var.left_margin; |
| 1805 | default_var.vsync_len = 4; |
Florian Tobias Schandinat | 7cf6079 | 2010-03-10 15:21:31 -0800 | [diff] [blame] | 1806 | viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo); |
Florian Tobias Schandinat | 7cf6079 | 2010-03-10 15:21:31 -0800 | [diff] [blame] | 1807 | viafbinfo->var = default_var; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1808 | |
| 1809 | if (viafb_dual_fb) { |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 1810 | viafbinfo1 = framebuffer_alloc(viafb_par_length, |
| 1811 | &vdev->pdev->dev); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1812 | if (!viafbinfo1) { |
| 1813 | printk(KERN_ERR |
| 1814 | "allocate the second framebuffer struct error\n"); |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 1815 | rc = -ENOMEM; |
Jonathan Corbet | 24b4d82 | 2010-04-22 13:48:09 -0600 | [diff] [blame] | 1816 | goto out_fb_release; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1817 | } |
| 1818 | viaparinfo1 = viafbinfo1->par; |
| 1819 | memcpy(viaparinfo1, viaparinfo, viafb_par_length); |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 1820 | viaparinfo1->vram_addr = viafb_second_offset; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1821 | viaparinfo1->memsize = viaparinfo->memsize - |
| 1822 | viafb_second_offset; |
| 1823 | viaparinfo->memsize = viafb_second_offset; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1824 | viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset; |
| 1825 | |
| 1826 | viaparinfo1->fbmem_used = viaparinfo->fbmem_used; |
| 1827 | viaparinfo1->fbmem_free = viaparinfo1->memsize - |
| 1828 | viaparinfo1->fbmem_used; |
| 1829 | viaparinfo->fbmem_free = viaparinfo->memsize; |
| 1830 | viaparinfo->fbmem_used = 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1831 | |
Florian Tobias Schandinat | 09cf118 | 2009-09-22 16:47:14 -0700 | [diff] [blame] | 1832 | viaparinfo->iga_path = IGA1; |
| 1833 | viaparinfo1->iga_path = IGA2; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1834 | memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info)); |
Florian Tobias Schandinat | c4df548 | 2009-09-22 16:47:24 -0700 | [diff] [blame] | 1835 | viafbinfo1->par = viaparinfo1; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1836 | viafbinfo1->screen_base = viafbinfo->screen_base + |
| 1837 | viafb_second_offset; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1838 | |
| 1839 | default_var.xres = viafb_second_xres; |
| 1840 | default_var.yres = viafb_second_yres; |
| 1841 | default_var.xres_virtual = viafb_second_virtual_xres; |
| 1842 | default_var.yres_virtual = viafb_second_virtual_yres; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1843 | default_var.bits_per_pixel = viafb_bpp1; |
| 1844 | default_var.pixclock = |
| 1845 | viafb_get_pixclock(viafb_second_xres, viafb_second_yres, |
| 1846 | viafb_refresh); |
| 1847 | default_var.left_margin = (viafb_second_xres >> 3) & 0xf8; |
| 1848 | default_var.right_margin = 32; |
| 1849 | default_var.upper_margin = 16; |
| 1850 | default_var.lower_margin = 4; |
| 1851 | default_var.hsync_len = default_var.left_margin; |
| 1852 | default_var.vsync_len = 4; |
| 1853 | |
| 1854 | viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1); |
| 1855 | viafb_check_var(&default_var, viafbinfo1); |
| 1856 | viafbinfo1->var = default_var; |
Florian Tobias Schandinat | 81228a3 | 2009-09-22 16:47:13 -0700 | [diff] [blame] | 1857 | viafb_update_fix(viafbinfo1); |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 1858 | viaparinfo1->depth = fb_get_color_depth(&viafbinfo1->var, |
| 1859 | &viafbinfo1->fix); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1860 | } |
| 1861 | |
Florian Tobias Schandinat | e17cea3 | 2010-03-10 15:21:41 -0800 | [diff] [blame] | 1862 | viafb_check_var(&viafbinfo->var, viafbinfo); |
Florian Tobias Schandinat | 81228a3 | 2009-09-22 16:47:13 -0700 | [diff] [blame] | 1863 | viafb_update_fix(viafbinfo); |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 1864 | viaparinfo->depth = fb_get_color_depth(&viafbinfo->var, |
| 1865 | &viafbinfo->fix); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1866 | default_var.activate = FB_ACTIVATE_NOW; |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 1867 | rc = fb_alloc_cmap(&viafbinfo->cmap, 256, 0); |
| 1868 | if (rc) |
| 1869 | goto out_fb1_release; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1870 | |
| 1871 | if (viafb_dual_fb && (viafb_primary_dev == LCD_Device) |
| 1872 | && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) { |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 1873 | rc = register_framebuffer(viafbinfo1); |
| 1874 | if (rc) |
| 1875 | goto out_dealloc_cmap; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1876 | } |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 1877 | rc = register_framebuffer(viafbinfo); |
| 1878 | if (rc) |
| 1879 | goto out_fb1_unreg_lcd_cle266; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1880 | |
| 1881 | if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device) |
| 1882 | || (viaparinfo->chip_info->gfx_chip_name != |
| 1883 | UNICHROME_CLE266))) { |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 1884 | rc = register_framebuffer(viafbinfo1); |
| 1885 | if (rc) |
| 1886 | goto out_fb_unreg; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1887 | } |
| 1888 | DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n", |
| 1889 | viafbinfo->node, viafbinfo->fix.id, default_var.xres, |
| 1890 | default_var.yres, default_var.bits_per_pixel); |
| 1891 | |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1892 | viafb_init_proc(viaparinfo->shared); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1893 | viafb_init_dac(IGA2); |
Daniel Drake | 751305d | 2010-10-28 18:23:01 +0100 | [diff] [blame^] | 1894 | |
| 1895 | #ifdef CONFIG_PM |
| 1896 | viafb_pm_register(&viafb_fb_pm_hooks); |
| 1897 | #endif |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1898 | return 0; |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 1899 | |
| 1900 | out_fb_unreg: |
| 1901 | unregister_framebuffer(viafbinfo); |
| 1902 | out_fb1_unreg_lcd_cle266: |
| 1903 | if (viafb_dual_fb && (viafb_primary_dev == LCD_Device) |
| 1904 | && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) |
| 1905 | unregister_framebuffer(viafbinfo1); |
| 1906 | out_dealloc_cmap: |
| 1907 | fb_dealloc_cmap(&viafbinfo->cmap); |
| 1908 | out_fb1_release: |
| 1909 | if (viafbinfo1) |
| 1910 | framebuffer_release(viafbinfo1); |
Harald Welte | 109771a | 2009-05-19 17:12:58 +0800 | [diff] [blame] | 1911 | out_fb_release: |
| 1912 | framebuffer_release(viafbinfo); |
| 1913 | return rc; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1914 | } |
| 1915 | |
Jonathan Corbet | f045f77 | 2009-12-01 20:29:39 -0700 | [diff] [blame] | 1916 | void __devexit via_fb_pci_remove(struct pci_dev *pdev) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1917 | { |
| 1918 | DEBUG_MSG(KERN_INFO "via_pci_remove!\n"); |
| 1919 | fb_dealloc_cmap(&viafbinfo->cmap); |
| 1920 | unregister_framebuffer(viafbinfo); |
| 1921 | if (viafb_dual_fb) |
| 1922 | unregister_framebuffer(viafbinfo1); |
Florian Tobias Schandinat | 2a91839 | 2010-09-05 01:33:28 +0000 | [diff] [blame] | 1923 | viafb_remove_proc(viaparinfo->shared); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1924 | framebuffer_release(viafbinfo); |
| 1925 | if (viafb_dual_fb) |
| 1926 | framebuffer_release(viafbinfo1); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1927 | } |
| 1928 | |
| 1929 | #ifndef MODULE |
| 1930 | static int __init viafb_setup(char *options) |
| 1931 | { |
| 1932 | char *this_opt; |
| 1933 | DEBUG_MSG(KERN_INFO "viafb_setup!\n"); |
| 1934 | |
| 1935 | if (!options || !*options) |
| 1936 | return 0; |
| 1937 | |
| 1938 | while ((this_opt = strsep(&options, ",")) != NULL) { |
| 1939 | if (!*this_opt) |
| 1940 | continue; |
| 1941 | |
| 1942 | if (!strncmp(this_opt, "viafb_mode1=", 12)) |
| 1943 | viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL); |
| 1944 | else if (!strncmp(this_opt, "viafb_mode=", 11)) |
| 1945 | viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL); |
| 1946 | else if (!strncmp(this_opt, "viafb_bpp1=", 11)) |
| 1947 | strict_strtoul(this_opt + 11, 0, |
| 1948 | (unsigned long *)&viafb_bpp1); |
| 1949 | else if (!strncmp(this_opt, "viafb_bpp=", 10)) |
| 1950 | strict_strtoul(this_opt + 10, 0, |
| 1951 | (unsigned long *)&viafb_bpp); |
| 1952 | else if (!strncmp(this_opt, "viafb_refresh1=", 15)) |
| 1953 | strict_strtoul(this_opt + 15, 0, |
| 1954 | (unsigned long *)&viafb_refresh1); |
| 1955 | else if (!strncmp(this_opt, "viafb_refresh=", 14)) |
| 1956 | strict_strtoul(this_opt + 14, 0, |
| 1957 | (unsigned long *)&viafb_refresh); |
| 1958 | else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21)) |
| 1959 | strict_strtoul(this_opt + 21, 0, |
| 1960 | (unsigned long *)&viafb_lcd_dsp_method); |
| 1961 | else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19)) |
| 1962 | strict_strtoul(this_opt + 19, 0, |
| 1963 | (unsigned long *)&viafb_lcd_panel_id); |
| 1964 | else if (!strncmp(this_opt, "viafb_accel=", 12)) |
| 1965 | strict_strtoul(this_opt + 12, 0, |
| 1966 | (unsigned long *)&viafb_accel); |
| 1967 | else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14)) |
| 1968 | strict_strtoul(this_opt + 14, 0, |
| 1969 | (unsigned long *)&viafb_SAMM_ON); |
| 1970 | else if (!strncmp(this_opt, "viafb_active_dev=", 17)) |
| 1971 | viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL); |
| 1972 | else if (!strncmp(this_opt, |
| 1973 | "viafb_display_hardware_layout=", 30)) |
| 1974 | strict_strtoul(this_opt + 30, 0, |
| 1975 | (unsigned long *)&viafb_display_hardware_layout); |
| 1976 | else if (!strncmp(this_opt, "viafb_second_size=", 18)) |
| 1977 | strict_strtoul(this_opt + 18, 0, |
| 1978 | (unsigned long *)&viafb_second_size); |
| 1979 | else if (!strncmp(this_opt, |
| 1980 | "viafb_platform_epia_dvi=", 24)) |
| 1981 | strict_strtoul(this_opt + 24, 0, |
| 1982 | (unsigned long *)&viafb_platform_epia_dvi); |
| 1983 | else if (!strncmp(this_opt, |
| 1984 | "viafb_device_lcd_dualedge=", 26)) |
| 1985 | strict_strtoul(this_opt + 26, 0, |
| 1986 | (unsigned long *)&viafb_device_lcd_dualedge); |
| 1987 | else if (!strncmp(this_opt, "viafb_bus_width=", 16)) |
| 1988 | strict_strtoul(this_opt + 16, 0, |
| 1989 | (unsigned long *)&viafb_bus_width); |
| 1990 | else if (!strncmp(this_opt, "viafb_lcd_mode=", 15)) |
| 1991 | strict_strtoul(this_opt + 15, 0, |
| 1992 | (unsigned long *)&viafb_lcd_mode); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 1993 | else if (!strncmp(this_opt, "viafb_lcd_port=", 15)) |
| 1994 | viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL); |
| 1995 | else if (!strncmp(this_opt, "viafb_dvi_port=", 15)) |
| 1996 | viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL); |
| 1997 | } |
| 1998 | return 0; |
| 1999 | } |
| 2000 | #endif |
| 2001 | |
Jonathan Corbet | f045f77 | 2009-12-01 20:29:39 -0700 | [diff] [blame] | 2002 | /* |
| 2003 | * These are called out of via-core for now. |
| 2004 | */ |
| 2005 | int __init viafb_init(void) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2006 | { |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 2007 | u32 dummy; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2008 | #ifndef MODULE |
| 2009 | char *option = NULL; |
| 2010 | if (fb_get_options("viafb", &option)) |
| 2011 | return -ENODEV; |
| 2012 | viafb_setup(option); |
| 2013 | #endif |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 2014 | if (parse_mode(viafb_mode, &dummy, &dummy) |
| 2015 | || parse_mode(viafb_mode1, &dummy, &dummy) |
Florian Tobias Schandinat | e17cea3 | 2010-03-10 15:21:41 -0800 | [diff] [blame] | 2016 | || viafb_bpp < 0 || viafb_bpp > 32 |
| 2017 | || viafb_bpp1 < 0 || viafb_bpp1 > 32 |
Florian Tobias Schandinat | fe9aab8 | 2010-03-10 15:21:34 -0800 | [diff] [blame] | 2018 | || parse_active_dev()) |
| 2019 | return -EINVAL; |
| 2020 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2021 | printk(KERN_INFO |
| 2022 | "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n", |
| 2023 | VERSION_MAJOR, VERSION_MINOR); |
Jonathan Corbet | f045f77 | 2009-12-01 20:29:39 -0700 | [diff] [blame] | 2024 | return 0; |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2025 | } |
| 2026 | |
Jonathan Corbet | f045f77 | 2009-12-01 20:29:39 -0700 | [diff] [blame] | 2027 | void __exit viafb_exit(void) |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2028 | { |
| 2029 | DEBUG_MSG(KERN_INFO "viafb_exit!\n"); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2030 | } |
| 2031 | |
| 2032 | static struct fb_ops viafb_ops = { |
| 2033 | .owner = THIS_MODULE, |
| 2034 | .fb_open = viafb_open, |
| 2035 | .fb_release = viafb_release, |
| 2036 | .fb_check_var = viafb_check_var, |
| 2037 | .fb_set_par = viafb_set_par, |
| 2038 | .fb_setcolreg = viafb_setcolreg, |
| 2039 | .fb_pan_display = viafb_pan_display, |
| 2040 | .fb_blank = viafb_blank, |
| 2041 | .fb_fillrect = viafb_fillrect, |
| 2042 | .fb_copyarea = viafb_copyarea, |
| 2043 | .fb_imageblit = viafb_imageblit, |
| 2044 | .fb_cursor = viafb_cursor, |
| 2045 | .fb_ioctl = viafb_ioctl, |
| 2046 | .fb_sync = viafb_sync, |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2047 | }; |
| 2048 | |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2049 | |
| 2050 | #ifdef MODULE |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2051 | module_param(viafb_mode, charp, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2052 | MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)"); |
| 2053 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2054 | module_param(viafb_mode1, charp, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2055 | MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)"); |
| 2056 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2057 | module_param(viafb_bpp, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2058 | MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)"); |
| 2059 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2060 | module_param(viafb_bpp1, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2061 | MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)"); |
| 2062 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2063 | module_param(viafb_refresh, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2064 | MODULE_PARM_DESC(viafb_refresh, |
| 2065 | "Set CRT viafb_refresh rate (default = 60)"); |
| 2066 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2067 | module_param(viafb_refresh1, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2068 | MODULE_PARM_DESC(viafb_refresh1, |
| 2069 | "Set CRT refresh rate (default = 60)"); |
| 2070 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2071 | module_param(viafb_lcd_panel_id, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2072 | MODULE_PARM_DESC(viafb_lcd_panel_id, |
| 2073 | "Set Flat Panel type(Default=1024x768)"); |
| 2074 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2075 | module_param(viafb_lcd_dsp_method, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2076 | MODULE_PARM_DESC(viafb_lcd_dsp_method, |
| 2077 | "Set Flat Panel display scaling method.(Default=Expandsion)"); |
| 2078 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2079 | module_param(viafb_SAMM_ON, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2080 | MODULE_PARM_DESC(viafb_SAMM_ON, |
| 2081 | "Turn on/off flag of SAMM(Default=OFF)"); |
| 2082 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2083 | module_param(viafb_accel, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2084 | MODULE_PARM_DESC(viafb_accel, |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 2085 | "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)"); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2086 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2087 | module_param(viafb_active_dev, charp, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2088 | MODULE_PARM_DESC(viafb_active_dev, "Specify active devices."); |
| 2089 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2090 | module_param(viafb_display_hardware_layout, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2091 | MODULE_PARM_DESC(viafb_display_hardware_layout, |
| 2092 | "Display Hardware Layout (LCD Only, DVI Only...,etc)"); |
| 2093 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2094 | module_param(viafb_second_size, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2095 | MODULE_PARM_DESC(viafb_second_size, |
| 2096 | "Set secondary device memory size"); |
| 2097 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2098 | module_param(viafb_dual_fb, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2099 | MODULE_PARM_DESC(viafb_dual_fb, |
| 2100 | "Turn on/off flag of dual framebuffer devices.(Default = OFF)"); |
| 2101 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2102 | module_param(viafb_platform_epia_dvi, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2103 | MODULE_PARM_DESC(viafb_platform_epia_dvi, |
| 2104 | "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)"); |
| 2105 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2106 | module_param(viafb_device_lcd_dualedge, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2107 | MODULE_PARM_DESC(viafb_device_lcd_dualedge, |
| 2108 | "Turn on/off flag of dual edge panel.(Default = OFF)"); |
| 2109 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2110 | module_param(viafb_bus_width, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2111 | MODULE_PARM_DESC(viafb_bus_width, |
| 2112 | "Set bus width of panel.(Default = 12)"); |
| 2113 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2114 | module_param(viafb_lcd_mode, int, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2115 | MODULE_PARM_DESC(viafb_lcd_mode, |
| 2116 | "Set Flat Panel mode(Default=OPENLDI)"); |
| 2117 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2118 | module_param(viafb_lcd_port, charp, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2119 | MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port."); |
| 2120 | |
Harald Welte | 93967be | 2009-09-22 16:47:32 -0700 | [diff] [blame] | 2121 | module_param(viafb_dvi_port, charp, S_IRUSR); |
Joseph Chan | 29b619f | 2008-10-15 22:03:27 -0700 | [diff] [blame] | 2122 | MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port."); |
| 2123 | |
| 2124 | MODULE_LICENSE("GPL"); |
| 2125 | #endif |