Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ps3fb/vram: Extract common GPU stuff into <asm/ps3gpu.h>

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: linux-fbdev-devel@lists.sourceforge.net
Cc: Jim Paris <jim@jtan.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Geert Uytterhoeven and committed by
Benjamin Herrenschmidt
d3352c9f 56ac72db

+110 -68
-3
arch/powerpc/include/asm/ps3.h
··· 520 520 u32 ps3_get_hw_thread_id(int cpu); 521 521 u64 ps3_get_spe_id(void *arg); 522 522 523 - /* mutex synchronizing GPU accesses and video mode changes */ 524 - extern struct mutex ps3_gpu_mutex; 525 - 526 523 #endif
+78
arch/powerpc/include/asm/ps3gpu.h
··· 1 + /* 2 + * PS3 GPU declarations. 3 + * 4 + * Copyright 2009 Sony Corporation 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; version 2 of the License. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program. 17 + * If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + 20 + #ifndef _ASM_POWERPC_PS3GPU_H 21 + #define _ASM_POWERPC_PS3GPU_H 22 + 23 + #include <linux/mutex.h> 24 + 25 + #include <asm/lv1call.h> 26 + 27 + 28 + #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC 0x101 29 + #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP 0x102 30 + 31 + #define L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP 0x600 32 + #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT 0x601 33 + #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT_SYNC 0x602 34 + 35 + #define L1GPU_FB_BLIT_WAIT_FOR_COMPLETION (1ULL << 32) 36 + 37 + #define L1GPU_DISPLAY_SYNC_HSYNC 1 38 + #define L1GPU_DISPLAY_SYNC_VSYNC 2 39 + 40 + 41 + /* mutex synchronizing GPU accesses and video mode changes */ 42 + extern struct mutex ps3_gpu_mutex; 43 + 44 + 45 + static inline int lv1_gpu_display_sync(u64 context_handle, u64 head, 46 + u64 ddr_offset) 47 + { 48 + return lv1_gpu_context_attribute(context_handle, 49 + L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, 50 + head, ddr_offset, 0, 0); 51 + } 52 + 53 + static inline int lv1_gpu_display_flip(u64 context_handle, u64 head, 54 + u64 ddr_offset) 55 + { 56 + return lv1_gpu_context_attribute(context_handle, 57 + L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 58 + head, ddr_offset, 0, 0); 59 + } 60 + 61 + static inline int lv1_gpu_fb_setup(u64 context_handle, u64 xdr_lpar, 62 + u64 xdr_size, u64 ioif_offset) 63 + { 64 + return lv1_gpu_context_attribute(context_handle, 65 + L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP, 66 + xdr_lpar, xdr_size, ioif_offset, 0); 67 + } 68 + 69 + static inline int lv1_gpu_fb_blit(u64 context_handle, u64 ddr_offset, 70 + u64 ioif_offset, u64 sync_width, u64 pitch) 71 + { 72 + return lv1_gpu_context_attribute(context_handle, 73 + L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 74 + ddr_offset, ioif_offset, sync_width, 75 + pitch); 76 + } 77 + 78 + #endif /* _ASM_POWERPC_PS3GPU_H */
+1
arch/powerpc/platforms/ps3/setup.c
··· 32 32 #include <asm/udbg.h> 33 33 #include <asm/prom.h> 34 34 #include <asm/lv1call.h> 35 + #include <asm/ps3gpu.h> 35 36 36 37 #include "platform.h" 37 38
+7 -14
drivers/block/ps3vram.c
··· 17 17 #include <asm/iommu.h> 18 18 #include <asm/lv1call.h> 19 19 #include <asm/ps3.h> 20 + #include <asm/ps3gpu.h> 20 21 21 22 22 23 #define DEVICE_NAME "ps3vram" ··· 46 45 47 46 #define NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN 0x0000030c 48 47 #define NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY 0x00000104 49 - 50 - #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT 0x601 51 48 52 49 #define CACHE_PAGE_PRESENT 1 53 50 #define CACHE_PAGE_DIRTY 2 ··· 183 184 priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET; 184 185 185 186 /* asking the HV for a blit will kick the FIFO */ 186 - status = lv1_gpu_context_attribute(priv->context_handle, 187 - L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 0, 188 - 0, 0, 0); 187 + status = lv1_gpu_fb_blit(priv->context_handle, 0, 0, 0, 0); 189 188 if (status) 190 - dev_err(&dev->core, 191 - "%s: lv1_gpu_context_attribute failed %d\n", __func__, 192 - status); 189 + dev_err(&dev->core, "%s: lv1_gpu_fb_blit failed %d\n", 190 + __func__, status); 193 191 194 192 priv->fifo_ptr = priv->fifo_base; 195 193 } ··· 202 206 (priv->fifo_ptr - priv->fifo_base) * sizeof(u32); 203 207 204 208 /* asking the HV for a blit will kick the FIFO */ 205 - status = lv1_gpu_context_attribute(priv->context_handle, 206 - L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 0, 207 - 0, 0, 0); 209 + status = lv1_gpu_fb_blit(priv->context_handle, 0, 0, 0, 0); 208 210 if (status) 209 - dev_err(&dev->core, 210 - "%s: lv1_gpu_context_attribute failed %d\n", __func__, 211 - status); 211 + dev_err(&dev->core, "%s: lv1_gpu_fb_blit failed %d\n", 212 + __func__, status); 212 213 213 214 if ((priv->fifo_ptr - priv->fifo_base) * sizeof(u32) > 214 215 FIFO_SIZE - 1024) {
+2 -1
drivers/ps3/ps3av_cmd.c
··· 21 21 #include <linux/module.h> 22 22 #include <linux/kernel.h> 23 23 #include <linux/delay.h> 24 + 24 25 #include <asm/ps3av.h> 25 - #include <asm/ps3fb.h> 26 26 #include <asm/ps3.h> 27 + #include <asm/ps3gpu.h> 27 28 28 29 #include "vuart.h" 29 30
+22 -50
drivers/video/ps3fb.c
··· 37 37 #include <asm/ps3av.h> 38 38 #include <asm/ps3fb.h> 39 39 #include <asm/ps3.h> 40 + #include <asm/ps3gpu.h> 40 41 41 42 42 43 #define DEVICE_NAME "ps3fb" 43 - 44 - #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC 0x101 45 - #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP 0x102 46 - #define L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP 0x600 47 - #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT 0x601 48 - #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT_SYNC 0x602 49 - 50 - #define L1GPU_FB_BLIT_WAIT_FOR_COMPLETION (1ULL << 32) 51 - 52 - #define L1GPU_DISPLAY_SYNC_HSYNC 1 53 - #define L1GPU_DISPLAY_SYNC_VSYNC 2 54 44 55 45 #define GPU_CMD_BUF_SIZE (2 * 1024 * 1024) 56 46 #define GPU_FB_START (64 * 1024) ··· 453 463 src_offset += GPU_FB_START; 454 464 455 465 mutex_lock(&ps3_gpu_mutex); 456 - status = lv1_gpu_context_attribute(ps3fb.context_handle, 457 - L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 458 - dst_offset, GPU_IOIF + src_offset, 459 - L1GPU_FB_BLIT_WAIT_FOR_COMPLETION | 460 - (width << 16) | height, 461 - line_length); 466 + status = lv1_gpu_fb_blit(ps3fb.context_handle, dst_offset, 467 + GPU_IOIF + src_offset, 468 + L1GPU_FB_BLIT_WAIT_FOR_COMPLETION | 469 + (width << 16) | height, 470 + line_length); 462 471 mutex_unlock(&ps3_gpu_mutex); 463 472 464 473 if (status) 465 - dev_err(dev, 466 - "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n", 467 - __func__, status); 474 + dev_err(dev, "%s: lv1_gpu_fb_blit failed: %d\n", __func__, 475 + status); 468 476 #ifdef HEAD_A 469 - status = lv1_gpu_context_attribute(ps3fb.context_handle, 470 - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 471 - 0, frame_offset, 0, 0); 477 + status = lv1_gpu_display_flip(ps3fb.context_handle, 0, frame_offset); 472 478 if (status) 473 - dev_err(dev, "%s: lv1_gpu_context_attribute FLIP failed: %d\n", 474 - __func__, status); 479 + dev_err(dev, "%s: lv1_gpu_display_flip failed: %d\n", __func__, 480 + status); 475 481 #endif 476 482 #ifdef HEAD_B 477 - status = lv1_gpu_context_attribute(ps3fb.context_handle, 478 - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 479 - 1, frame_offset, 0, 0); 483 + status = lv1_gpu_display_flip(ps3fb.context_handle, 1, frame_offset); 480 484 if (status) 481 - dev_err(dev, "%s: lv1_gpu_context_attribute FLIP failed: %d\n", 482 - __func__, status); 485 + dev_err(dev, "%s: lv1_gpu_display_flip failed: %d\n", __func__, 486 + status); 483 487 #endif 484 488 } 485 489 ··· 1004 1020 init_waitqueue_head(&ps3fb.wait_vsync); 1005 1021 1006 1022 #ifdef HEAD_A 1007 - status = lv1_gpu_context_attribute(0x0, 1008 - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, 1009 - 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); 1023 + status = lv1_gpu_display_sync(0x0, 0, L1GPU_DISPLAY_SYNC_VSYNC); 1010 1024 if (status) { 1011 - dev_err(&dev->core, 1012 - "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: " 1013 - "%d\n", 1025 + dev_err(&dev->core, "%s: lv1_gpu_display_sync failed: %d\n", 1014 1026 __func__, status); 1015 1027 retval = -ENODEV; 1016 1028 goto err_close_device; 1017 1029 } 1018 1030 #endif 1019 1031 #ifdef HEAD_B 1020 - status = lv1_gpu_context_attribute(0x0, 1021 - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, 1022 - 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); 1023 - 1032 + status = lv1_gpu_display_sync(0x0, 1, L1GPU_DISPLAY_SYNC_VSYNC); 1024 1033 if (status) { 1025 - dev_err(&dev->core, 1026 - "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: " 1027 - "%d\n", 1034 + dev_err(&dev->core, "%s: lv1_gpu_display_sync failed: %d\n", 1028 1035 __func__, status); 1029 1036 retval = -ENODEV; 1030 1037 goto err_close_device; ··· 1045 1070 &lpar_reports, &lpar_reports_size); 1046 1071 if (status) { 1047 1072 dev_err(&dev->core, 1048 - "%s: lv1_gpu_context_attribute failed: %d\n", __func__, 1073 + "%s: lv1_gpu_context_allocate failed: %d\n", __func__, 1049 1074 status); 1050 1075 goto err_gpu_memory_free; 1051 1076 } ··· 1112 1137 ps3fb_videomemory.address, GPU_IOIF, xdr_lpar, 1113 1138 ps3fb_videomemory.size); 1114 1139 1115 - status = lv1_gpu_context_attribute(ps3fb.context_handle, 1116 - L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP, 1117 - xdr_lpar, GPU_CMD_BUF_SIZE, 1118 - GPU_IOIF, 0); 1140 + status = lv1_gpu_fb_setup(ps3fb.context_handle, xdr_lpar, 1141 + GPU_CMD_BUF_SIZE, GPU_IOIF); 1119 1142 if (status) { 1120 - dev_err(&dev->core, 1121 - "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n", 1143 + dev_err(&dev->core, "%s: lv1_gpu_fb_setup failed: %d\n", 1122 1144 __func__, status); 1123 1145 retval = -ENXIO; 1124 1146 goto err_context_unmap;