Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. |
| 3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. |
| 4 | |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public |
| 7 | * License as published by the Free Software Foundation; |
| 8 | * either version 2, or (at your option) any later version. |
| 9 | |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even |
| 12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR |
| 13 | * A PARTICULAR PURPOSE.See the GNU General Public License |
| 14 | * for more details. |
| 15 | |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 20 | */ |
| 21 | #include "global.h" |
| 22 | |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame^] | 23 | static int hw_bitblt_1(void __iomem *engine, u8 op, u32 width, u32 height, |
| 24 | u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y, |
| 25 | u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y, |
| 26 | u32 fg_color, u32 bg_color, u8 fill_rop) |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 27 | { |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame^] | 28 | u32 ge_cmd = 0, tmp, i; |
| 29 | |
| 30 | if (!op || op > 3) { |
| 31 | printk(KERN_WARNING "hw_bitblt_1: Invalid operation: %d\n", op); |
| 32 | return -EINVAL; |
| 33 | } |
| 34 | |
| 35 | if (op != VIA_BITBLT_FILL && !src_mem && src_addr == dst_addr) { |
| 36 | if (src_x < dst_x) { |
| 37 | ge_cmd |= 0x00008000; |
| 38 | src_x += width - 1; |
| 39 | dst_x += width - 1; |
| 40 | } |
| 41 | if (src_y < dst_y) { |
| 42 | ge_cmd |= 0x00004000; |
| 43 | src_y += height - 1; |
| 44 | dst_y += height - 1; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | if (op == VIA_BITBLT_FILL) { |
| 49 | switch (fill_rop) { |
| 50 | case 0x00: /* blackness */ |
| 51 | case 0x5A: /* pattern inversion */ |
| 52 | case 0xF0: /* pattern copy */ |
| 53 | case 0xFF: /* whiteness */ |
| 54 | break; |
| 55 | default: |
| 56 | printk(KERN_WARNING "hw_bitblt_1: Invalid fill rop: " |
| 57 | "%u\n", fill_rop); |
| 58 | return -EINVAL; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | switch (dst_bpp) { |
| 63 | case 8: |
| 64 | tmp = 0x00000000; |
| 65 | break; |
| 66 | case 16: |
| 67 | tmp = 0x00000100; |
| 68 | break; |
| 69 | case 32: |
| 70 | tmp = 0x00000300; |
| 71 | break; |
| 72 | default: |
| 73 | printk(KERN_WARNING "hw_bitblt_1: Unsupported bpp %d\n", |
| 74 | dst_bpp); |
| 75 | return -EINVAL; |
| 76 | } |
| 77 | writel(tmp, engine + 0x04); |
| 78 | |
| 79 | if (op != VIA_BITBLT_FILL) { |
| 80 | if (src_x & (op == VIA_BITBLT_MONO ? 0xFFFF8000 : 0xFFFFF000) |
| 81 | || src_y & 0xFFFFF000) { |
| 82 | printk(KERN_WARNING "hw_bitblt_1: Unsupported source " |
| 83 | "x/y %d %d\n", src_x, src_y); |
| 84 | return -EINVAL; |
| 85 | } |
| 86 | tmp = src_x | (src_y << 16); |
| 87 | writel(tmp, engine + 0x08); |
| 88 | } |
| 89 | |
| 90 | if (dst_x & 0xFFFFF000 || dst_y & 0xFFFFF000) { |
| 91 | printk(KERN_WARNING "hw_bitblt_1: Unsupported destination x/y " |
| 92 | "%d %d\n", dst_x, dst_y); |
| 93 | return -EINVAL; |
| 94 | } |
| 95 | tmp = dst_x | (dst_y << 16); |
| 96 | writel(tmp, engine + 0x0C); |
| 97 | |
| 98 | if ((width - 1) & 0xFFFFF000 || (height - 1) & 0xFFFFF000) { |
| 99 | printk(KERN_WARNING "hw_bitblt_1: Unsupported width/height " |
| 100 | "%d %d\n", width, height); |
| 101 | return -EINVAL; |
| 102 | } |
| 103 | tmp = (width - 1) | ((height - 1) << 16); |
| 104 | writel(tmp, engine + 0x10); |
| 105 | |
| 106 | if (op != VIA_BITBLT_COLOR) |
| 107 | writel(fg_color, engine + 0x18); |
| 108 | |
| 109 | if (op == VIA_BITBLT_MONO) |
| 110 | writel(bg_color, engine + 0x1C); |
| 111 | |
| 112 | if (op != VIA_BITBLT_FILL) { |
| 113 | tmp = src_mem ? 0 : src_addr; |
| 114 | if (dst_addr & 0xE0000007) { |
| 115 | printk(KERN_WARNING "hw_bitblt_1: Unsupported source " |
| 116 | "address %X\n", tmp); |
| 117 | return -EINVAL; |
| 118 | } |
| 119 | tmp >>= 3; |
| 120 | writel(tmp, engine + 0x30); |
| 121 | } |
| 122 | |
| 123 | if (dst_addr & 0xE0000007) { |
| 124 | printk(KERN_WARNING "hw_bitblt_1: Unsupported destination " |
| 125 | "address %X\n", dst_addr); |
| 126 | return -EINVAL; |
| 127 | } |
| 128 | tmp = dst_addr >> 3; |
| 129 | writel(tmp, engine + 0x34); |
| 130 | |
| 131 | if (op == VIA_BITBLT_FILL) |
| 132 | tmp = 0; |
| 133 | else |
| 134 | tmp = src_pitch; |
| 135 | if (tmp & 0xFFFFC007 || dst_pitch & 0xFFFFC007) { |
| 136 | printk(KERN_WARNING "hw_bitblt_1: Unsupported pitch %X %X\n", |
| 137 | tmp, dst_pitch); |
| 138 | return -EINVAL; |
| 139 | } |
| 140 | tmp = (tmp >> 3) | (dst_pitch << (16 - 3)); |
| 141 | writel(tmp, engine + 0x38); |
| 142 | |
| 143 | if (op == VIA_BITBLT_FILL) |
| 144 | ge_cmd |= fill_rop << 24 | 0x00002000 | 0x00000001; |
| 145 | else { |
| 146 | ge_cmd |= 0xCC000000; /* ROP=SRCCOPY */ |
| 147 | if (src_mem) |
| 148 | ge_cmd |= 0x00000040; |
| 149 | if (op == VIA_BITBLT_MONO) |
| 150 | ge_cmd |= 0x00000002 | 0x00000100 | 0x00020000; |
| 151 | else |
| 152 | ge_cmd |= 0x00000001; |
| 153 | } |
| 154 | writel(ge_cmd, engine); |
| 155 | |
| 156 | if (op == VIA_BITBLT_FILL || !src_mem) |
| 157 | return 0; |
| 158 | |
| 159 | tmp = (width * height * (op == VIA_BITBLT_MONO ? 1 : (dst_bpp >> 3)) + |
| 160 | 3) >> 2; |
| 161 | |
| 162 | for (i = 0; i < tmp; i++) |
| 163 | writel(src_mem[i], engine + VIA_MMIO_BLTBASE); |
| 164 | |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height, |
| 169 | u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y, |
| 170 | u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y, |
| 171 | u32 fg_color, u32 bg_color, u8 fill_rop) |
| 172 | { |
| 173 | u32 ge_cmd = 0, tmp, i; |
| 174 | |
| 175 | if (!op || op > 3) { |
| 176 | printk(KERN_WARNING "hw_bitblt_2: Invalid operation: %d\n", op); |
| 177 | return -EINVAL; |
| 178 | } |
| 179 | |
| 180 | if (op != VIA_BITBLT_FILL && !src_mem && src_addr == dst_addr) { |
| 181 | if (src_x < dst_x) { |
| 182 | ge_cmd |= 0x00008000; |
| 183 | src_x += width - 1; |
| 184 | dst_x += width - 1; |
| 185 | } |
| 186 | if (src_y < dst_y) { |
| 187 | ge_cmd |= 0x00004000; |
| 188 | src_y += height - 1; |
| 189 | dst_y += height - 1; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | if (op == VIA_BITBLT_FILL) { |
| 194 | switch (fill_rop) { |
| 195 | case 0x00: /* blackness */ |
| 196 | case 0x5A: /* pattern inversion */ |
| 197 | case 0xF0: /* pattern copy */ |
| 198 | case 0xFF: /* whiteness */ |
| 199 | break; |
| 200 | default: |
| 201 | printk(KERN_WARNING "hw_bitblt_2: Invalid fill rop: " |
| 202 | "%u\n", fill_rop); |
| 203 | return -EINVAL; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | switch (dst_bpp) { |
| 208 | case 8: |
| 209 | tmp = 0x00000000; |
| 210 | break; |
| 211 | case 16: |
| 212 | tmp = 0x00000100; |
| 213 | break; |
| 214 | case 32: |
| 215 | tmp = 0x00000300; |
| 216 | break; |
| 217 | default: |
| 218 | printk(KERN_WARNING "hw_bitblt_2: Unsupported bpp %d\n", |
| 219 | dst_bpp); |
| 220 | return -EINVAL; |
| 221 | } |
| 222 | writel(tmp, engine + 0x04); |
| 223 | |
| 224 | if (op == VIA_BITBLT_FILL) |
| 225 | tmp = 0; |
| 226 | else |
| 227 | tmp = src_pitch; |
| 228 | if (tmp & 0xFFFFC007 || dst_pitch & 0xFFFFC007) { |
| 229 | printk(KERN_WARNING "hw_bitblt_2: Unsupported pitch %X %X\n", |
| 230 | tmp, dst_pitch); |
| 231 | return -EINVAL; |
| 232 | } |
| 233 | tmp = (tmp >> 3) | (dst_pitch << (16 - 3)); |
| 234 | writel(tmp, engine + 0x08); |
| 235 | |
| 236 | if ((width - 1) & 0xFFFFF000 || (height - 1) & 0xFFFFF000) { |
| 237 | printk(KERN_WARNING "hw_bitblt_2: Unsupported width/height " |
| 238 | "%d %d\n", width, height); |
| 239 | return -EINVAL; |
| 240 | } |
| 241 | tmp = (width - 1) | ((height - 1) << 16); |
| 242 | writel(tmp, engine + 0x0C); |
| 243 | |
| 244 | if (dst_x & 0xFFFFF000 || dst_y & 0xFFFFF000) { |
| 245 | printk(KERN_WARNING "hw_bitblt_2: Unsupported destination x/y " |
| 246 | "%d %d\n", dst_x, dst_y); |
| 247 | return -EINVAL; |
| 248 | } |
| 249 | tmp = dst_x | (dst_y << 16); |
| 250 | writel(tmp, engine + 0x10); |
| 251 | |
| 252 | if (dst_addr & 0xE0000007) { |
| 253 | printk(KERN_WARNING "hw_bitblt_2: Unsupported destination " |
| 254 | "address %X\n", dst_addr); |
| 255 | return -EINVAL; |
| 256 | } |
| 257 | tmp = dst_addr >> 3; |
| 258 | writel(tmp, engine + 0x14); |
| 259 | |
| 260 | if (op != VIA_BITBLT_FILL) { |
| 261 | if (src_x & (op == VIA_BITBLT_MONO ? 0xFFFF8000 : 0xFFFFF000) |
| 262 | || src_y & 0xFFFFF000) { |
| 263 | printk(KERN_WARNING "hw_bitblt_2: Unsupported source " |
| 264 | "x/y %d %d\n", src_x, src_y); |
| 265 | return -EINVAL; |
| 266 | } |
| 267 | tmp = src_x | (src_y << 16); |
| 268 | writel(tmp, engine + 0x18); |
| 269 | |
| 270 | tmp = src_mem ? 0 : src_addr; |
| 271 | if (dst_addr & 0xE0000007) { |
| 272 | printk(KERN_WARNING "hw_bitblt_2: Unsupported source " |
| 273 | "address %X\n", tmp); |
| 274 | return -EINVAL; |
| 275 | } |
| 276 | tmp >>= 3; |
| 277 | writel(tmp, engine + 0x1C); |
| 278 | } |
| 279 | |
| 280 | if (op != VIA_BITBLT_COLOR) |
| 281 | writel(fg_color, engine + 0x4C); |
| 282 | |
| 283 | if (op == VIA_BITBLT_MONO) |
| 284 | writel(bg_color, engine + 0x50); |
| 285 | |
| 286 | if (op == VIA_BITBLT_FILL) |
| 287 | ge_cmd |= fill_rop << 24 | 0x00002000 | 0x00000001; |
| 288 | else { |
| 289 | ge_cmd |= 0xCC000000; /* ROP=SRCCOPY */ |
| 290 | if (src_mem) |
| 291 | ge_cmd |= 0x00000040; |
| 292 | if (op == VIA_BITBLT_MONO) |
| 293 | ge_cmd |= 0x00000002 | 0x00000100 | 0x00020000; |
| 294 | else |
| 295 | ge_cmd |= 0x00000001; |
| 296 | } |
| 297 | writel(ge_cmd, engine); |
| 298 | |
| 299 | if (op == VIA_BITBLT_FILL || !src_mem) |
| 300 | return 0; |
| 301 | |
| 302 | tmp = (width * height * (op == VIA_BITBLT_MONO ? 1 : (dst_bpp >> 3)) + |
| 303 | 3) >> 2; |
| 304 | |
| 305 | for (i = 0; i < tmp; i++) |
| 306 | writel(src_mem[i], engine + VIA_MMIO_BLTBASE); |
| 307 | |
| 308 | return 0; |
| 309 | } |
| 310 | |
| 311 | void viafb_init_accel(struct viafb_shared *shared) |
| 312 | { |
| 313 | switch (shared->chip_info.gfx_chip_name) { |
| 314 | case UNICHROME_CLE266: |
| 315 | case UNICHROME_K400: |
| 316 | case UNICHROME_K800: |
| 317 | case UNICHROME_PM800: |
| 318 | case UNICHROME_CN700: |
| 319 | case UNICHROME_CX700: |
| 320 | case UNICHROME_CN750: |
| 321 | case UNICHROME_K8M890: |
| 322 | case UNICHROME_P4M890: |
| 323 | case UNICHROME_P4M900: |
| 324 | shared->hw_bitblt = hw_bitblt_1; |
| 325 | break; |
| 326 | case UNICHROME_VX800: |
| 327 | shared->hw_bitblt = hw_bitblt_2; |
| 328 | break; |
| 329 | default: |
| 330 | shared->hw_bitblt = NULL; |
| 331 | } |
| 332 | |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 333 | viaparinfo->fbmem_free -= CURSOR_SIZE; |
| 334 | viaparinfo->cursor_start = viaparinfo->fbmem_free; |
| 335 | viaparinfo->fbmem_used += CURSOR_SIZE; |
| 336 | |
| 337 | /* Reverse 8*1024 memory space for cursor image */ |
| 338 | viaparinfo->fbmem_free -= (CURSOR_SIZE + VQ_SIZE); |
| 339 | viaparinfo->VQ_start = viaparinfo->fbmem_free; |
| 340 | viaparinfo->VQ_end = viaparinfo->VQ_start + VQ_SIZE - 1; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame^] | 341 | viaparinfo->fbmem_used += (CURSOR_SIZE + VQ_SIZE); |
| 342 | } |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 343 | |
| 344 | void viafb_init_2d_engine(void) |
| 345 | { |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame^] | 346 | u32 dwVQStartAddr, dwVQEndAddr; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 347 | u32 dwVQLen, dwVQStartL, dwVQEndL, dwVQStartEndH; |
| 348 | |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 349 | /* Init AGP and VQ regs */ |
| 350 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 351 | case UNICHROME_K8M890: |
| 352 | case UNICHROME_P4M900: |
| 353 | writel(0x00100000, viaparinfo->io_virt + VIA_REG_CR_TRANSET); |
| 354 | writel(0x680A0000, viaparinfo->io_virt + VIA_REG_CR_TRANSPACE); |
| 355 | writel(0x02000000, viaparinfo->io_virt + VIA_REG_CR_TRANSPACE); |
| 356 | break; |
| 357 | |
| 358 | default: |
| 359 | writel(0x00100000, viaparinfo->io_virt + VIA_REG_TRANSET); |
| 360 | writel(0x00000000, viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 361 | writel(0x00333004, viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 362 | writel(0x60000000, viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 363 | writel(0x61000000, viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 364 | writel(0x62000000, viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 365 | writel(0x63000000, viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 366 | writel(0x64000000, viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 367 | writel(0x7D000000, viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 368 | |
| 369 | writel(0xFE020000, viaparinfo->io_virt + VIA_REG_TRANSET); |
| 370 | writel(0x00000000, viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 371 | break; |
| 372 | } |
| 373 | if (viaparinfo->VQ_start != 0) { |
| 374 | /* Enable VQ */ |
| 375 | dwVQStartAddr = viaparinfo->VQ_start; |
| 376 | dwVQEndAddr = viaparinfo->VQ_end; |
| 377 | |
| 378 | dwVQStartL = 0x50000000 | (dwVQStartAddr & 0xFFFFFF); |
| 379 | dwVQEndL = 0x51000000 | (dwVQEndAddr & 0xFFFFFF); |
| 380 | dwVQStartEndH = 0x52000000 | |
| 381 | ((dwVQStartAddr & 0xFF000000) >> 24) | |
| 382 | ((dwVQEndAddr & 0xFF000000) >> 16); |
| 383 | dwVQLen = 0x53000000 | (VQ_SIZE >> 3); |
| 384 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 385 | case UNICHROME_K8M890: |
| 386 | case UNICHROME_P4M900: |
| 387 | dwVQStartL |= 0x20000000; |
| 388 | dwVQEndL |= 0x20000000; |
| 389 | dwVQStartEndH |= 0x20000000; |
| 390 | dwVQLen |= 0x20000000; |
| 391 | break; |
| 392 | default: |
| 393 | break; |
| 394 | } |
| 395 | |
| 396 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 397 | case UNICHROME_K8M890: |
| 398 | case UNICHROME_P4M900: |
| 399 | writel(0x00100000, |
| 400 | viaparinfo->io_virt + VIA_REG_CR_TRANSET); |
| 401 | writel(dwVQStartEndH, |
| 402 | viaparinfo->io_virt + VIA_REG_CR_TRANSPACE); |
| 403 | writel(dwVQStartL, |
| 404 | viaparinfo->io_virt + VIA_REG_CR_TRANSPACE); |
| 405 | writel(dwVQEndL, |
| 406 | viaparinfo->io_virt + VIA_REG_CR_TRANSPACE); |
| 407 | writel(dwVQLen, |
| 408 | viaparinfo->io_virt + VIA_REG_CR_TRANSPACE); |
| 409 | writel(0x74301001, |
| 410 | viaparinfo->io_virt + VIA_REG_CR_TRANSPACE); |
| 411 | writel(0x00000000, |
| 412 | viaparinfo->io_virt + VIA_REG_CR_TRANSPACE); |
| 413 | break; |
| 414 | default: |
| 415 | writel(0x00FE0000, |
| 416 | viaparinfo->io_virt + VIA_REG_TRANSET); |
| 417 | writel(0x080003FE, |
| 418 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 419 | writel(0x0A00027C, |
| 420 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 421 | writel(0x0B000260, |
| 422 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 423 | writel(0x0C000274, |
| 424 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 425 | writel(0x0D000264, |
| 426 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 427 | writel(0x0E000000, |
| 428 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 429 | writel(0x0F000020, |
| 430 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 431 | writel(0x1000027E, |
| 432 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 433 | writel(0x110002FE, |
| 434 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 435 | writel(0x200F0060, |
| 436 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 437 | |
| 438 | writel(0x00000006, |
| 439 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 440 | writel(0x40008C0F, |
| 441 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 442 | writel(0x44000000, |
| 443 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 444 | writel(0x45080C04, |
| 445 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 446 | writel(0x46800408, |
| 447 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 448 | |
| 449 | writel(dwVQStartEndH, |
| 450 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 451 | writel(dwVQStartL, |
| 452 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 453 | writel(dwVQEndL, |
| 454 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 455 | writel(dwVQLen, |
| 456 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 457 | break; |
| 458 | } |
| 459 | } else { |
| 460 | /* Disable VQ */ |
| 461 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 462 | case UNICHROME_K8M890: |
| 463 | case UNICHROME_P4M900: |
| 464 | writel(0x00100000, |
| 465 | viaparinfo->io_virt + VIA_REG_CR_TRANSET); |
| 466 | writel(0x74301000, |
| 467 | viaparinfo->io_virt + VIA_REG_CR_TRANSPACE); |
| 468 | break; |
| 469 | default: |
| 470 | writel(0x00FE0000, |
| 471 | viaparinfo->io_virt + VIA_REG_TRANSET); |
| 472 | writel(0x00000004, |
| 473 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 474 | writel(0x40008C0F, |
| 475 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 476 | writel(0x44000000, |
| 477 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 478 | writel(0x45080C04, |
| 479 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 480 | writel(0x46800408, |
| 481 | viaparinfo->io_virt + VIA_REG_TRANSPACE); |
| 482 | break; |
| 483 | } |
| 484 | } |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | void viafb_hw_cursor_init(void) |
| 488 | { |
| 489 | /* Set Cursor Image Base Address */ |
| 490 | writel(viaparinfo->cursor_start, |
| 491 | viaparinfo->io_virt + VIA_REG_CURSOR_MODE); |
| 492 | writel(0x0, viaparinfo->io_virt + VIA_REG_CURSOR_POS); |
| 493 | writel(0x0, viaparinfo->io_virt + VIA_REG_CURSOR_ORG); |
| 494 | writel(0x0, viaparinfo->io_virt + VIA_REG_CURSOR_BG); |
| 495 | writel(0x0, viaparinfo->io_virt + VIA_REG_CURSOR_FG); |
| 496 | } |
| 497 | |
| 498 | void viafb_show_hw_cursor(struct fb_info *info, int Status) |
| 499 | { |
| 500 | u32 temp; |
| 501 | u32 iga_path = ((struct viafb_par *)(info->par))->iga_path; |
| 502 | |
| 503 | temp = readl(viaparinfo->io_virt + VIA_REG_CURSOR_MODE); |
| 504 | switch (Status) { |
| 505 | case HW_Cursor_ON: |
| 506 | temp |= 0x1; |
| 507 | break; |
| 508 | case HW_Cursor_OFF: |
| 509 | temp &= 0xFFFFFFFE; |
| 510 | break; |
| 511 | } |
| 512 | switch (iga_path) { |
| 513 | case IGA2: |
| 514 | temp |= 0x80000000; |
| 515 | break; |
| 516 | case IGA1: |
| 517 | default: |
| 518 | temp &= 0x7FFFFFFF; |
| 519 | } |
| 520 | writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_MODE); |
| 521 | } |
| 522 | |
| 523 | int viafb_wait_engine_idle(void) |
| 524 | { |
| 525 | int loop = 0; |
| 526 | |
| 527 | while (!(readl(viaparinfo->io_virt + VIA_REG_STATUS) & |
Roel Kluin | 2bd8c47 | 2009-03-31 15:25:36 -0700 | [diff] [blame] | 528 | VIA_VR_QUEUE_BUSY) && (loop < MAXLOOP)) { |
| 529 | loop++; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 530 | cpu_relax(); |
Roel Kluin | 2bd8c47 | 2009-03-31 15:25:36 -0700 | [diff] [blame] | 531 | } |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 532 | |
| 533 | while ((readl(viaparinfo->io_virt + VIA_REG_STATUS) & |
| 534 | (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) && |
Roel Kluin | 2bd8c47 | 2009-03-31 15:25:36 -0700 | [diff] [blame] | 535 | (loop < MAXLOOP)) { |
| 536 | loop++; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 537 | cpu_relax(); |
Roel Kluin | 2bd8c47 | 2009-03-31 15:25:36 -0700 | [diff] [blame] | 538 | } |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 539 | |
| 540 | return loop >= MAXLOOP; |
| 541 | } |