Commit d3352c9f1e8e2f2989d9686c8aa8acb4842fe75e

Authored by Geert Uytterhoeven
Committed by Benjamin Herrenschmidt
1 parent 56ac72dba5

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>

Showing 6 changed files with 110 additions and 68 deletions Side-by-side Diff

arch/powerpc/include/asm/ps3.h
... ... @@ -520,8 +520,5 @@
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
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 */
arch/powerpc/platforms/ps3/setup.c
... ... @@ -32,6 +32,7 @@
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  
drivers/block/ps3vram.c
... ... @@ -17,6 +17,7 @@
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,8 +47,6 @@
46 47 #define NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN 0x0000030c
47 48 #define NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY 0x00000104
48 49  
49   -#define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT 0x601
50   -
51 50 #define CACHE_PAGE_PRESENT 1
52 51 #define CACHE_PAGE_DIRTY 2
53 52  
54 53  
... ... @@ -184,13 +183,10 @@
184 183 priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET;
185 184  
186 185 /* asking the HV for a blit will kick the FIFO */
187   - status = lv1_gpu_context_attribute(priv->context_handle,
188   - L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 0,
189   - 0, 0, 0);
  186 + status = lv1_gpu_fb_blit(priv->context_handle, 0, 0, 0, 0);
190 187 if (status)
191   - dev_err(&dev->core,
192   - "%s: lv1_gpu_context_attribute failed %d\n", __func__,
193   - status);
  188 + dev_err(&dev->core, "%s: lv1_gpu_fb_blit failed %d\n",
  189 + __func__, status);
194 190  
195 191 priv->fifo_ptr = priv->fifo_base;
196 192 }
197 193  
... ... @@ -206,13 +202,10 @@
206 202 (priv->fifo_ptr - priv->fifo_base) * sizeof(u32);
207 203  
208 204 /* asking the HV for a blit will kick the FIFO */
209   - status = lv1_gpu_context_attribute(priv->context_handle,
210   - L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 0,
211   - 0, 0, 0);
  205 + status = lv1_gpu_fb_blit(priv->context_handle, 0, 0, 0, 0);
212 206 if (status)
213   - dev_err(&dev->core,
214   - "%s: lv1_gpu_context_attribute failed %d\n", __func__,
215   - status);
  207 + dev_err(&dev->core, "%s: lv1_gpu_fb_blit failed %d\n",
  208 + __func__, status);
216 209  
217 210 if ((priv->fifo_ptr - priv->fifo_base) * sizeof(u32) >
218 211 FIFO_SIZE - 1024) {
drivers/ps3/ps3av_cmd.c
... ... @@ -21,9 +21,10 @@
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  
drivers/video/ps3fb.c
... ... @@ -37,21 +37,11 @@
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  
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   -
55 45 #define GPU_CMD_BUF_SIZE (2 * 1024 * 1024)
56 46 #define GPU_FB_START (64 * 1024)
57 47 #define GPU_IOIF (0x0d000000UL)
58 48  
59 49  
60 50  
61 51  
62 52  
... ... @@ -463,33 +453,27 @@
463 453 src_offset += GPU_FB_START;
464 454  
465 455 mutex_lock(&ps3_gpu_mutex);
466   - status = lv1_gpu_context_attribute(ps3fb.context_handle,
467   - L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
468   - dst_offset, GPU_IOIF + src_offset,
469   - L1GPU_FB_BLIT_WAIT_FOR_COMPLETION |
470   - (width << 16) | height,
471   - line_length);
  456 + status = lv1_gpu_fb_blit(ps3fb.context_handle, dst_offset,
  457 + GPU_IOIF + src_offset,
  458 + L1GPU_FB_BLIT_WAIT_FOR_COMPLETION |
  459 + (width << 16) | height,
  460 + line_length);
472 461 mutex_unlock(&ps3_gpu_mutex);
473 462  
474 463 if (status)
475   - dev_err(dev,
476   - "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n",
477   - __func__, status);
  464 + dev_err(dev, "%s: lv1_gpu_fb_blit failed: %d\n", __func__,
  465 + status);
478 466 #ifdef HEAD_A
479   - status = lv1_gpu_context_attribute(ps3fb.context_handle,
480   - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP,
481   - 0, frame_offset, 0, 0);
  467 + status = lv1_gpu_display_flip(ps3fb.context_handle, 0, frame_offset);
482 468 if (status)
483   - dev_err(dev, "%s: lv1_gpu_context_attribute FLIP failed: %d\n",
484   - __func__, status);
  469 + dev_err(dev, "%s: lv1_gpu_display_flip failed: %d\n", __func__,
  470 + status);
485 471 #endif
486 472 #ifdef HEAD_B
487   - status = lv1_gpu_context_attribute(ps3fb.context_handle,
488   - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP,
489   - 1, frame_offset, 0, 0);
  473 + status = lv1_gpu_display_flip(ps3fb.context_handle, 1, frame_offset);
490 474 if (status)
491   - dev_err(dev, "%s: lv1_gpu_context_attribute FLIP failed: %d\n",
492   - __func__, status);
  475 + dev_err(dev, "%s: lv1_gpu_display_flip failed: %d\n", __func__,
  476 + status);
493 477 #endif
494 478 }
495 479  
496 480  
497 481  
498 482  
... ... @@ -1020,27 +1004,18 @@
1020 1004 init_waitqueue_head(&ps3fb.wait_vsync);
1021 1005  
1022 1006 #ifdef HEAD_A
1023   - status = lv1_gpu_context_attribute(0x0,
1024   - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
1025   - 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0);
  1007 + status = lv1_gpu_display_sync(0x0, 0, L1GPU_DISPLAY_SYNC_VSYNC);
1026 1008 if (status) {
1027   - dev_err(&dev->core,
1028   - "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: "
1029   - "%d\n",
  1009 + dev_err(&dev->core, "%s: lv1_gpu_display_sync failed: %d\n",
1030 1010 __func__, status);
1031 1011 retval = -ENODEV;
1032 1012 goto err_close_device;
1033 1013 }
1034 1014 #endif
1035 1015 #ifdef HEAD_B
1036   - status = lv1_gpu_context_attribute(0x0,
1037   - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
1038   - 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0);
1039   -
  1016 + status = lv1_gpu_display_sync(0x0, 1, L1GPU_DISPLAY_SYNC_VSYNC);
1040 1017 if (status) {
1041   - dev_err(&dev->core,
1042   - "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: "
1043   - "%d\n",
  1018 + dev_err(&dev->core, "%s: lv1_gpu_display_sync failed: %d\n",
1044 1019 __func__, status);
1045 1020 retval = -ENODEV;
1046 1021 goto err_close_device;
... ... @@ -1070,7 +1045,7 @@
1070 1045 &lpar_reports, &lpar_reports_size);
1071 1046 if (status) {
1072 1047 dev_err(&dev->core,
1073   - "%s: lv1_gpu_context_attribute failed: %d\n", __func__,
  1048 + "%s: lv1_gpu_context_allocate failed: %d\n", __func__,
1074 1049 status);
1075 1050 goto err_gpu_memory_free;
1076 1051 }
1077 1052  
... ... @@ -1137,13 +1112,10 @@
1137 1112 ps3fb_videomemory.address, GPU_IOIF, xdr_lpar,
1138 1113 ps3fb_videomemory.size);
1139 1114  
1140   - status = lv1_gpu_context_attribute(ps3fb.context_handle,
1141   - L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP,
1142   - xdr_lpar, GPU_CMD_BUF_SIZE,
1143   - GPU_IOIF, 0);
  1115 + status = lv1_gpu_fb_setup(ps3fb.context_handle, xdr_lpar,
  1116 + GPU_CMD_BUF_SIZE, GPU_IOIF);
1144 1117 if (status) {
1145   - dev_err(&dev->core,
1146   - "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n",
  1118 + dev_err(&dev->core, "%s: lv1_gpu_fb_setup failed: %d\n",
1147 1119 __func__, status);
1148 1120 retval = -ENXIO;
1149 1121 goto err_context_unmap;