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