diff options
author | Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | 2009-06-10 00:38:48 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-06-14 23:26:20 -0400 |
commit | d3352c9f1e8e2f2989d9686c8aa8acb4842fe75e (patch) | |
tree | ea8a18d573a45f913d9e0669a17a0b39835e55ff | |
parent | 56ac72dba5d24a477d281b985797d5e62d3f5c2e (diff) |
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>
-rw-r--r-- | arch/powerpc/include/asm/ps3.h | 3 | ||||
-rw-r--r-- | arch/powerpc/include/asm/ps3gpu.h | 78 | ||||
-rw-r--r-- | arch/powerpc/platforms/ps3/setup.c | 1 | ||||
-rw-r--r-- | drivers/block/ps3vram.c | 21 | ||||
-rw-r--r-- | drivers/ps3/ps3av_cmd.c | 3 | ||||
-rw-r--r-- | drivers/video/ps3fb.c | 72 |
6 files changed, 110 insertions, 68 deletions
diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h index cdb6fd814de8..b9e4987986dd 100644 --- a/arch/powerpc/include/asm/ps3.h +++ b/arch/powerpc/include/asm/ps3.h | |||
@@ -520,7 +520,4 @@ void ps3_sync_irq(int node); | |||
520 | u32 ps3_get_hw_thread_id(int cpu); | 520 | u32 ps3_get_hw_thread_id(int cpu); |
521 | u64 ps3_get_spe_id(void *arg); | 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 | #endif | 523 | #endif |
diff --git a/arch/powerpc/include/asm/ps3gpu.h b/arch/powerpc/include/asm/ps3gpu.h new file mode 100644 index 000000000000..1037efae4a51 --- /dev/null +++ b/arch/powerpc/include/asm/ps3gpu.h | |||
@@ -0,0 +1,78 @@ | |||
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 */ | ||
diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c index 1a7b5ae0c83e..149bea2ce583 100644 --- a/arch/powerpc/platforms/ps3/setup.c +++ b/arch/powerpc/platforms/ps3/setup.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <asm/udbg.h> | 32 | #include <asm/udbg.h> |
33 | #include <asm/prom.h> | 33 | #include <asm/prom.h> |
34 | #include <asm/lv1call.h> | 34 | #include <asm/lv1call.h> |
35 | #include <asm/ps3gpu.h> | ||
35 | 36 | ||
36 | #include "platform.h" | 37 | #include "platform.h" |
37 | 38 | ||
diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 83c14533aea5..2c2ea9cb207b 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <asm/iommu.h> | 17 | #include <asm/iommu.h> |
18 | #include <asm/lv1call.h> | 18 | #include <asm/lv1call.h> |
19 | #include <asm/ps3.h> | 19 | #include <asm/ps3.h> |
20 | #include <asm/ps3gpu.h> | ||
20 | 21 | ||
21 | 22 | ||
22 | #define DEVICE_NAME "ps3vram" | 23 | #define DEVICE_NAME "ps3vram" |
@@ -46,8 +47,6 @@ | |||
46 | #define NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN 0x0000030c | 47 | #define NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN 0x0000030c |
47 | #define NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY 0x00000104 | 48 | #define NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY 0x00000104 |
48 | 49 | ||
49 | #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT 0x601 | ||
50 | |||
51 | #define CACHE_PAGE_PRESENT 1 | 50 | #define CACHE_PAGE_PRESENT 1 |
52 | #define CACHE_PAGE_DIRTY 2 | 51 | #define CACHE_PAGE_DIRTY 2 |
53 | 52 | ||
@@ -184,13 +183,10 @@ static void ps3vram_rewind_ring(struct ps3_system_bus_device *dev) | |||
184 | priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET; | 183 | priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET; |
185 | 184 | ||
186 | /* asking the HV for a blit will kick the FIFO */ | 185 | /* asking the HV for a blit will kick the FIFO */ |
187 | status = lv1_gpu_context_attribute(priv->context_handle, | 186 | status = lv1_gpu_fb_blit(priv->context_handle, 0, 0, 0, 0); |
188 | L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 0, | ||
189 | 0, 0, 0); | ||
190 | if (status) | 187 | if (status) |
191 | dev_err(&dev->core, | 188 | dev_err(&dev->core, "%s: lv1_gpu_fb_blit failed %d\n", |
192 | "%s: lv1_gpu_context_attribute failed %d\n", __func__, | 189 | __func__, status); |
193 | status); | ||
194 | 190 | ||
195 | priv->fifo_ptr = priv->fifo_base; | 191 | priv->fifo_ptr = priv->fifo_base; |
196 | } | 192 | } |
@@ -206,13 +202,10 @@ static void ps3vram_fire_ring(struct ps3_system_bus_device *dev) | |||
206 | (priv->fifo_ptr - priv->fifo_base) * sizeof(u32); | 202 | (priv->fifo_ptr - priv->fifo_base) * sizeof(u32); |
207 | 203 | ||
208 | /* asking the HV for a blit will kick the FIFO */ | 204 | /* asking the HV for a blit will kick the FIFO */ |
209 | status = lv1_gpu_context_attribute(priv->context_handle, | 205 | status = lv1_gpu_fb_blit(priv->context_handle, 0, 0, 0, 0); |
210 | L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, 0, | ||
211 | 0, 0, 0); | ||
212 | if (status) | 206 | if (status) |
213 | dev_err(&dev->core, | 207 | dev_err(&dev->core, "%s: lv1_gpu_fb_blit failed %d\n", |
214 | "%s: lv1_gpu_context_attribute failed %d\n", __func__, | 208 | __func__, status); |
215 | status); | ||
216 | 209 | ||
217 | if ((priv->fifo_ptr - priv->fifo_base) * sizeof(u32) > | 210 | if ((priv->fifo_ptr - priv->fifo_base) * sizeof(u32) > |
218 | FIFO_SIZE - 1024) { | 211 | FIFO_SIZE - 1024) { |
diff --git a/drivers/ps3/ps3av_cmd.c b/drivers/ps3/ps3av_cmd.c index 716596e8e5b0..f555fedd5073 100644 --- a/drivers/ps3/ps3av_cmd.c +++ b/drivers/ps3/ps3av_cmd.c | |||
@@ -21,9 +21,10 @@ | |||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | |||
24 | #include <asm/ps3av.h> | 25 | #include <asm/ps3av.h> |
25 | #include <asm/ps3fb.h> | ||
26 | #include <asm/ps3.h> | 26 | #include <asm/ps3.h> |
27 | #include <asm/ps3gpu.h> | ||
27 | 28 | ||
28 | #include "vuart.h" | 29 | #include "vuart.h" |
29 | 30 | ||
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c index a61c1d89bd87..13c876c6e32c 100644 --- a/drivers/video/ps3fb.c +++ b/drivers/video/ps3fb.c | |||
@@ -37,21 +37,11 @@ | |||
37 | #include <asm/ps3av.h> | 37 | #include <asm/ps3av.h> |
38 | #include <asm/ps3fb.h> | 38 | #include <asm/ps3fb.h> |
39 | #include <asm/ps3.h> | 39 | #include <asm/ps3.h> |
40 | #include <asm/ps3gpu.h> | ||
40 | 41 | ||
41 | 42 | ||
42 | #define DEVICE_NAME "ps3fb" | 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 | #define GPU_CMD_BUF_SIZE (2 * 1024 * 1024) | 45 | #define GPU_CMD_BUF_SIZE (2 * 1024 * 1024) |
56 | #define GPU_FB_START (64 * 1024) | 46 | #define GPU_FB_START (64 * 1024) |
57 | #define GPU_IOIF (0x0d000000UL) | 47 | #define GPU_IOIF (0x0d000000UL) |
@@ -463,33 +453,27 @@ static void ps3fb_sync_image(struct device *dev, u64 frame_offset, | |||
463 | src_offset += GPU_FB_START; | 453 | src_offset += GPU_FB_START; |
464 | 454 | ||
465 | mutex_lock(&ps3_gpu_mutex); | 455 | mutex_lock(&ps3_gpu_mutex); |
466 | status = lv1_gpu_context_attribute(ps3fb.context_handle, | 456 | status = lv1_gpu_fb_blit(ps3fb.context_handle, dst_offset, |
467 | L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT, | 457 | GPU_IOIF + src_offset, |
468 | dst_offset, GPU_IOIF + src_offset, | 458 | L1GPU_FB_BLIT_WAIT_FOR_COMPLETION | |
469 | L1GPU_FB_BLIT_WAIT_FOR_COMPLETION | | 459 | (width << 16) | height, |
470 | (width << 16) | height, | 460 | line_length); |
471 | line_length); | ||
472 | mutex_unlock(&ps3_gpu_mutex); | 461 | mutex_unlock(&ps3_gpu_mutex); |
473 | 462 | ||
474 | if (status) | 463 | if (status) |
475 | dev_err(dev, | 464 | dev_err(dev, "%s: lv1_gpu_fb_blit failed: %d\n", __func__, |
476 | "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n", | 465 | status); |
477 | __func__, status); | ||
478 | #ifdef HEAD_A | 466 | #ifdef HEAD_A |
479 | status = lv1_gpu_context_attribute(ps3fb.context_handle, | 467 | status = lv1_gpu_display_flip(ps3fb.context_handle, 0, frame_offset); |
480 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, | ||
481 | 0, frame_offset, 0, 0); | ||
482 | if (status) | 468 | if (status) |
483 | dev_err(dev, "%s: lv1_gpu_context_attribute FLIP failed: %d\n", | 469 | dev_err(dev, "%s: lv1_gpu_display_flip failed: %d\n", __func__, |
484 | __func__, status); | 470 | status); |
485 | #endif | 471 | #endif |
486 | #ifdef HEAD_B | 472 | #ifdef HEAD_B |
487 | status = lv1_gpu_context_attribute(ps3fb.context_handle, | 473 | status = lv1_gpu_display_flip(ps3fb.context_handle, 1, frame_offset); |
488 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, | ||
489 | 1, frame_offset, 0, 0); | ||
490 | if (status) | 474 | if (status) |
491 | dev_err(dev, "%s: lv1_gpu_context_attribute FLIP failed: %d\n", | 475 | dev_err(dev, "%s: lv1_gpu_display_flip failed: %d\n", __func__, |
492 | __func__, status); | 476 | status); |
493 | #endif | 477 | #endif |
494 | } | 478 | } |
495 | 479 | ||
@@ -1020,27 +1004,18 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev) | |||
1020 | init_waitqueue_head(&ps3fb.wait_vsync); | 1004 | init_waitqueue_head(&ps3fb.wait_vsync); |
1021 | 1005 | ||
1022 | #ifdef HEAD_A | 1006 | #ifdef HEAD_A |
1023 | status = lv1_gpu_context_attribute(0x0, | 1007 | status = lv1_gpu_display_sync(0x0, 0, L1GPU_DISPLAY_SYNC_VSYNC); |
1024 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
1025 | 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
1026 | if (status) { | 1008 | if (status) { |
1027 | dev_err(&dev->core, | 1009 | dev_err(&dev->core, "%s: lv1_gpu_display_sync failed: %d\n", |
1028 | "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: " | ||
1029 | "%d\n", | ||
1030 | __func__, status); | 1010 | __func__, status); |
1031 | retval = -ENODEV; | 1011 | retval = -ENODEV; |
1032 | goto err_close_device; | 1012 | goto err_close_device; |
1033 | } | 1013 | } |
1034 | #endif | 1014 | #endif |
1035 | #ifdef HEAD_B | 1015 | #ifdef HEAD_B |
1036 | status = lv1_gpu_context_attribute(0x0, | 1016 | status = lv1_gpu_display_sync(0x0, 1, L1GPU_DISPLAY_SYNC_VSYNC); |
1037 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
1038 | 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
1039 | |||
1040 | if (status) { | 1017 | if (status) { |
1041 | dev_err(&dev->core, | 1018 | dev_err(&dev->core, "%s: lv1_gpu_display_sync failed: %d\n", |
1042 | "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: " | ||
1043 | "%d\n", | ||
1044 | __func__, status); | 1019 | __func__, status); |
1045 | retval = -ENODEV; | 1020 | retval = -ENODEV; |
1046 | goto err_close_device; | 1021 | goto err_close_device; |
@@ -1070,7 +1045,7 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev) | |||
1070 | &lpar_reports, &lpar_reports_size); | 1045 | &lpar_reports, &lpar_reports_size); |
1071 | if (status) { | 1046 | if (status) { |
1072 | dev_err(&dev->core, | 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 | status); | 1049 | status); |
1075 | goto err_gpu_memory_free; | 1050 | goto err_gpu_memory_free; |
1076 | } | 1051 | } |
@@ -1137,13 +1112,10 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev) | |||
1137 | ps3fb_videomemory.address, GPU_IOIF, xdr_lpar, | 1112 | ps3fb_videomemory.address, GPU_IOIF, xdr_lpar, |
1138 | ps3fb_videomemory.size); | 1113 | ps3fb_videomemory.size); |
1139 | 1114 | ||
1140 | status = lv1_gpu_context_attribute(ps3fb.context_handle, | 1115 | status = lv1_gpu_fb_setup(ps3fb.context_handle, xdr_lpar, |
1141 | L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP, | 1116 | GPU_CMD_BUF_SIZE, GPU_IOIF); |
1142 | xdr_lpar, GPU_CMD_BUF_SIZE, | ||
1143 | GPU_IOIF, 0); | ||
1144 | if (status) { | 1117 | if (status) { |
1145 | dev_err(&dev->core, | 1118 | dev_err(&dev->core, "%s: lv1_gpu_fb_setup failed: %d\n", |
1146 | "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n", | ||
1147 | __func__, status); | 1119 | __func__, status); |
1148 | retval = -ENXIO; | 1120 | retval = -ENXIO; |
1149 | goto err_context_unmap; | 1121 | goto err_context_unmap; |