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