]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/video/ps3fb.c
ps3fb: don't keep the borders for non-fullscreen modes in XDR memory
[mv-sheeva.git] / drivers / video / ps3fb.c
1 /*
2  *  linux/drivers/video/ps3fb.c -- PS3 GPU frame buffer device
3  *
4  *      Copyright (C) 2006 Sony Computer Entertainment Inc.
5  *      Copyright 2006, 2007 Sony Corporation
6  *
7  *  This file is based on :
8  *
9  *  linux/drivers/video/vfb.c -- Virtual frame buffer device
10  *
11  *      Copyright (C) 2002 James Simmons
12  *
13  *      Copyright (C) 1997 Geert Uytterhoeven
14  *
15  *  This file is subject to the terms and conditions of the GNU General Public
16  *  License. See the file COPYING in the main directory of this archive for
17  *  more details.
18  */
19
20 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #include <linux/errno.h>
23 #include <linux/string.h>
24 #include <linux/mm.h>
25 #include <linux/interrupt.h>
26 #include <linux/console.h>
27 #include <linux/ioctl.h>
28 #include <linux/kthread.h>
29 #include <linux/freezer.h>
30 #include <linux/uaccess.h>
31 #include <linux/fb.h>
32 #include <linux/init.h>
33
34 #include <asm/abs_addr.h>
35 #include <asm/lv1call.h>
36 #include <asm/ps3av.h>
37 #include <asm/ps3fb.h>
38 #include <asm/ps3.h>
39
40
41 #define DEVICE_NAME             "ps3fb"
42
43 #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC    0x101
44 #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP    0x102
45 #define L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP        0x600
46 #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT         0x601
47 #define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT_SYNC    0x602
48
49 #define L1GPU_FB_BLIT_WAIT_FOR_COMPLETION       (1ULL << 32)
50
51 #define L1GPU_DISPLAY_SYNC_HSYNC                1
52 #define L1GPU_DISPLAY_SYNC_VSYNC                2
53
54 #define DDR_SIZE                                (0)     /* used no ddr */
55 #define GPU_CMD_BUF_SIZE                        (64 * 1024)
56 #define GPU_IOIF                                (0x0d000000UL)
57 #define GPU_ALIGN_UP(x)                         _ALIGN_UP((x), 64)
58
59 #define PS3FB_FULL_MODE_BIT                     0x80
60
61 #define GPU_INTR_STATUS_VSYNC_0                 0       /* vsync on head A */
62 #define GPU_INTR_STATUS_VSYNC_1                 1       /* vsync on head B */
63 #define GPU_INTR_STATUS_FLIP_0                  3       /* flip head A */
64 #define GPU_INTR_STATUS_FLIP_1                  4       /* flip head B */
65 #define GPU_INTR_STATUS_QUEUE_0                 5       /* queue head A */
66 #define GPU_INTR_STATUS_QUEUE_1                 6       /* queue head B */
67
68 #define GPU_DRIVER_INFO_VERSION                 0x211
69
70 /* gpu internals */
71 struct display_head {
72         u64 be_time_stamp;
73         u32 status;
74         u32 offset;
75         u32 res1;
76         u32 res2;
77         u32 field;
78         u32 reserved1;
79
80         u64 res3;
81         u32 raster;
82
83         u64 vblank_count;
84         u32 field_vsync;
85         u32 reserved2;
86 };
87
88 struct gpu_irq {
89         u32 irq_outlet;
90         u32 status;
91         u32 mask;
92         u32 video_cause;
93         u32 graph_cause;
94         u32 user_cause;
95
96         u32 res1;
97         u64 res2;
98
99         u32 reserved[4];
100 };
101
102 struct gpu_driver_info {
103         u32 version_driver;
104         u32 version_gpu;
105         u32 memory_size;
106         u32 hardware_channel;
107
108         u32 nvcore_frequency;
109         u32 memory_frequency;
110
111         u32 reserved[1063];
112         struct display_head display_head[8];
113         struct gpu_irq irq;
114 };
115
116 struct ps3fb_priv {
117         unsigned int irq_no;
118
119         u64 context_handle, memory_handle;
120         void *xdr_ea;
121         size_t xdr_size;
122         struct gpu_driver_info *dinfo;
123
124         u64 vblank_count;       /* frame count */
125         wait_queue_head_t wait_vsync;
126
127         atomic_t ext_flip;      /* on/off flip with vsync */
128         atomic_t f_count;       /* fb_open count */
129         int is_blanked;
130         int is_kicked;
131         struct task_struct *task;
132 };
133 static struct ps3fb_priv ps3fb;
134
135 struct ps3fb_par {
136         u32 pseudo_palette[16];
137         int mode_id, new_mode_id;
138         int res_index;
139         unsigned int num_frames;        /* num of frame buffers */
140         unsigned int width;
141         unsigned int height;
142         unsigned long full_offset;      /* start of fullscreen DDR fb */
143         unsigned long fb_offset;        /* start of actual DDR fb */
144 };
145
146 struct ps3fb_res_table {
147         u32 xres;
148         u32 yres;
149         u32 xoff;
150         u32 yoff;
151         u32 type;
152 };
153 #define PS3FB_RES_FULL 1
154 static const struct ps3fb_res_table ps3fb_res[] = {
155         /* res_x,y   margin_x,y  full */
156         {  720,  480,  72,  48 , 0},
157         {  720,  576,  72,  58 , 0},
158         { 1280,  720,  78,  38 , 0},
159         { 1920, 1080, 116,  58 , 0},
160         /* full mode */
161         {  720,  480,   0,   0 , PS3FB_RES_FULL},
162         {  720,  576,   0,   0 , PS3FB_RES_FULL},
163         { 1280,  720,   0,   0 , PS3FB_RES_FULL},
164         { 1920, 1080,   0,   0 , PS3FB_RES_FULL},
165         /* vesa: normally full mode */
166         { 1280,  768,   0,   0 , 0},
167         { 1280, 1024,   0,   0 , 0},
168         { 1920, 1200,   0,   0 , 0},
169         {    0,    0,   0,   0 , 0} };
170
171 /* default resolution */
172 #define GPU_RES_INDEX   0               /* 720 x 480 */
173
174 static const struct fb_videomode ps3fb_modedb[] = {
175     /* 60 Hz broadcast modes (modes "1" to "5") */
176     {
177         /* 480i */
178         "480i", 60, 576, 384, 74074, 130, 89, 78, 57, 63, 6,
179         FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
180     },    {
181         /* 480p */
182         "480p", 60, 576, 384, 37037, 130, 89, 78, 57, 63, 6,
183         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
184     },    {
185         /* 720p */
186         "720p", 60, 1124, 644, 13481, 298, 148, 57, 44, 80, 5,
187         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
188     },    {
189         /* 1080i */
190         "1080i", 60, 1688, 964, 13481, 264, 160, 94, 62, 88, 5,
191         FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
192     },    {
193         /* 1080p */
194         "1080p", 60, 1688, 964, 6741, 264, 160, 94, 62, 88, 5,
195         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
196     },
197
198     /* 50 Hz broadcast modes (modes "6" to "10") */
199     {
200         /* 576i */
201         "576i", 50, 576, 460, 74074, 142, 83, 97, 63, 63, 5,
202         FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
203     },    {
204         /* 576p */
205         "576p", 50, 576, 460, 37037, 142, 83, 97, 63, 63, 5,
206         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
207     },    {
208         /* 720p */
209         "720p", 50, 1124, 644, 13468, 298, 478, 57, 44, 80, 5,
210         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
211     },    {
212         /* 1080 */
213         "1080i", 50, 1688, 964, 13468, 264, 600, 94, 62, 88, 5,
214         FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
215     },    {
216         /* 1080p */
217         "1080p", 50, 1688, 964, 6734, 264, 600, 94, 62, 88, 5,
218         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
219     },
220
221     /* VESA modes (modes "11" to "13") */
222     {
223         /* WXGA */
224         "wxga", 60, 1280, 768, 12924, 160, 24, 29, 3, 136, 6,
225         0, FB_VMODE_NONINTERLACED,
226         FB_MODE_IS_VESA
227     }, {
228         /* SXGA */
229         "sxga", 60, 1280, 1024, 9259, 248, 48, 38, 1, 112, 3,
230         FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED,
231         FB_MODE_IS_VESA
232     }, {
233         /* WUXGA */
234         "wuxga", 60, 1920, 1200, 6494, 80, 48, 26, 3, 32, 6,
235         FB_SYNC_HOR_HIGH_ACT, FB_VMODE_NONINTERLACED,
236         FB_MODE_IS_VESA
237     },
238
239     /* 60 Hz broadcast modes (full resolution versions of modes "1" to "5") */
240     {
241         /* 480if */
242         "480if", 60, 720, 480, 74074, 58, 17, 30, 9, 63, 6,
243         FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
244     }, {
245         /* 480pf */
246         "480pf", 60, 720, 480, 37037, 58, 17, 30, 9, 63, 6,
247         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
248     }, {
249         /* 720pf */
250         "720pf", 60, 1280, 720, 13481, 220, 70, 19, 6, 80, 5,
251         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
252     }, {
253         /* 1080if */
254         "1080if", 60, 1920, 1080, 13481, 148, 44, 36, 4, 88, 5,
255         FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
256     }, {
257         /* 1080pf */
258         "1080pf", 60, 1920, 1080, 6741, 148, 44, 36, 4, 88, 5,
259         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
260     },
261
262     /* 50 Hz broadcast modes (full resolution versions of modes "6" to "10") */
263     {
264         /* 576if */
265         "576if", 50, 720, 576, 74074, 70, 11, 39, 5, 63, 5,
266         FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
267     }, {
268         /* 576pf */
269         "576pf", 50, 720, 576, 37037, 70, 11, 39, 5, 63, 5,
270         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
271     }, {
272         /* 720pf */
273         "720pf", 50, 1280, 720, 13468, 220, 400, 19, 6, 80, 5,
274         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
275     }, {
276         /* 1080if */
277         "1080f", 50, 1920, 1080, 13468, 148, 484, 36, 4, 88, 5,
278         FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
279     }, {
280         /* 1080pf */
281         "1080pf", 50, 1920, 1080, 6734, 148, 484, 36, 4, 88, 5,
282         FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
283     }
284 };
285
286
287 #define HEAD_A
288 #define HEAD_B
289
290 #define X_OFF(i)        (ps3fb_res[i].xoff)     /* left/right margin (pixel) */
291 #define Y_OFF(i)        (ps3fb_res[i].yoff)     /* top/bottom margin (pixel) */
292 #define WIDTH(i)        (ps3fb_res[i].xres)     /* width of FB */
293 #define HEIGHT(i)       (ps3fb_res[i].yres)     /* height of FB */
294 #define BPP             4                       /* number of bytes per pixel */
295
296 /* Start of the virtual frame buffer (relative to fullscreen ) */
297 #define VP_OFF(i)       ((WIDTH(i) * Y_OFF(i) + X_OFF(i)) * BPP)
298
299
300 static int ps3fb_mode;
301 module_param(ps3fb_mode, int, 0);
302
303 static char *mode_option __devinitdata;
304
305 static int ps3fb_get_res_table(u32 xres, u32 yres, int mode)
306 {
307         int full_mode;
308         unsigned int i;
309         u32 x, y, f;
310
311         full_mode = (mode & PS3FB_FULL_MODE_BIT) ? PS3FB_RES_FULL : 0;
312         for (i = 0;; i++) {
313                 x = ps3fb_res[i].xres;
314                 y = ps3fb_res[i].yres;
315                 f = ps3fb_res[i].type;
316
317                 if (!x) {
318                         pr_debug("ERROR: ps3fb_get_res_table()\n");
319                         return -1;
320                 }
321
322                 if (full_mode == PS3FB_RES_FULL && f != PS3FB_RES_FULL)
323                         continue;
324
325                 if (x == xres && (yres == 0 || y == yres))
326                         break;
327
328                 x = x - 2 * ps3fb_res[i].xoff;
329                 y = y - 2 * ps3fb_res[i].yoff;
330                 if (x == xres && (yres == 0 || y == yres))
331                         break;
332         }
333         return i;
334 }
335
336 static unsigned int ps3fb_find_mode(const struct fb_var_screeninfo *var,
337                                     u32 *line_length)
338 {
339         unsigned int i, mode;
340
341         for (i = 0; i < ARRAY_SIZE(ps3fb_modedb); i++)
342                 if (var->xres == ps3fb_modedb[i].xres &&
343                     var->yres == ps3fb_modedb[i].yres &&
344                     var->pixclock == ps3fb_modedb[i].pixclock &&
345                     var->hsync_len == ps3fb_modedb[i].hsync_len &&
346                     var->vsync_len == ps3fb_modedb[i].vsync_len &&
347                     var->left_margin == ps3fb_modedb[i].left_margin &&
348                     var->right_margin == ps3fb_modedb[i].right_margin &&
349                     var->upper_margin == ps3fb_modedb[i].upper_margin &&
350                     var->lower_margin == ps3fb_modedb[i].lower_margin &&
351                     var->sync == ps3fb_modedb[i].sync &&
352                     (var->vmode & FB_VMODE_MASK) == ps3fb_modedb[i].vmode) {
353                         /* Cropped broadcast modes use the full line_length */
354                         *line_length =
355                             ps3fb_modedb[i < 10 ? i + 13 : i].xres * 4;
356                         /* Full broadcast modes have the full mode bit set */
357                         mode = i > 12 ? (i - 12) | PS3FB_FULL_MODE_BIT : i + 1;
358
359                         pr_debug("ps3fb_find_mode: mode %u\n", mode);
360                         return mode;
361                 }
362
363         pr_debug("ps3fb_find_mode: mode not found\n");
364         return 0;
365 }
366
367 static const struct fb_videomode *ps3fb_default_mode(int id)
368 {
369         u32 mode = id & PS3AV_MODE_MASK;
370         u32 flags;
371
372         if (mode < 1 || mode > 13)
373                 return NULL;
374
375         flags = id & ~PS3AV_MODE_MASK;
376
377         if (mode <= 10 && flags & PS3FB_FULL_MODE_BIT) {
378                 /* Full broadcast mode */
379                 return &ps3fb_modedb[mode + 12];
380         }
381
382         return &ps3fb_modedb[mode - 1];
383 }
384
385 static void ps3fb_sync_image(struct device *dev, u64 frame_offset,
386                              u64 dst_offset, u64 src_offset, u32 width,
387                              u32 height, u64 line_length)
388 {
389         int status;
390
391         status = lv1_gpu_context_attribute(ps3fb.context_handle,
392                                            L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
393                                            dst_offset, GPU_IOIF + src_offset,
394                                            L1GPU_FB_BLIT_WAIT_FOR_COMPLETION |
395                                            (width << 16) | height,
396                                            line_length);
397         if (status)
398                 dev_err(dev,
399                         "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n",
400                         __func__, status);
401 #ifdef HEAD_A
402         status = lv1_gpu_context_attribute(ps3fb.context_handle,
403                                            L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP,
404                                            0, frame_offset, 0, 0);
405         if (status)
406                 dev_err(dev, "%s: lv1_gpu_context_attribute FLIP failed: %d\n",
407                         __func__, status);
408 #endif
409 #ifdef HEAD_B
410         status = lv1_gpu_context_attribute(ps3fb.context_handle,
411                                            L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP,
412                                            1, frame_offset, 0, 0);
413         if (status)
414                 dev_err(dev, "%s: lv1_gpu_context_attribute FLIP failed: %d\n",
415                         __func__, status);
416 #endif
417 }
418
419 static int ps3fb_sync(struct fb_info *info, u32 frame)
420 {
421         struct ps3fb_par *par = info->par;
422         int i, error = 0;
423         u32 xres, yres;
424         u64 line_length, base;
425
426         acquire_console_sem();
427
428         if (frame > par->num_frames - 1) {
429                 dev_dbg(info->device, "%s: invalid frame number (%u)\n",
430                         __func__, frame);
431                 error = -EINVAL;
432                 goto out;
433         }
434
435         i = par->res_index;
436         xres = ps3fb_res[i].xres;
437         yres = ps3fb_res[i].yres;
438
439         line_length = xres * BPP;
440         base = frame * yres * line_length;
441
442         ps3fb_sync_image(info->device, base + par->full_offset,
443                          base + par->fb_offset, base, par->width, par->height,
444                          line_length);
445
446 out:
447         release_console_sem();
448         return error;
449 }
450
451 static int ps3fb_open(struct fb_info *info, int user)
452 {
453         atomic_inc(&ps3fb.f_count);
454         return 0;
455 }
456
457 static int ps3fb_release(struct fb_info *info, int user)
458 {
459         if (atomic_dec_and_test(&ps3fb.f_count)) {
460                 if (atomic_read(&ps3fb.ext_flip)) {
461                         atomic_set(&ps3fb.ext_flip, 0);
462                         ps3fb_sync(info, 0);    /* single buffer */
463                 }
464         }
465         return 0;
466 }
467
468     /*
469      *  Setting the video mode has been split into two parts.
470      *  First part, xxxfb_check_var, must not write anything
471      *  to hardware, it should only verify and adjust var.
472      *  This means it doesn't alter par but it does use hardware
473      *  data from it to check this var.
474      */
475
476 static int ps3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
477 {
478         u32 line_length;
479         int mode;
480
481         dev_dbg(info->device, "var->xres:%u info->var.xres:%u\n", var->xres,
482                 info->var.xres);
483         dev_dbg(info->device, "var->yres:%u info->var.yres:%u\n", var->yres,
484                 info->var.yres);
485
486         /* FIXME For now we do exact matches only */
487         mode = ps3fb_find_mode(var, &line_length);
488         if (!mode)
489                 return -EINVAL;
490
491         /*
492          *  FB_VMODE_CONUPDATE and FB_VMODE_SMOOTH_XPAN are equal!
493          *  as FB_VMODE_SMOOTH_XPAN is only used internally
494          */
495
496         if (var->vmode & FB_VMODE_CONUPDATE) {
497                 var->vmode |= FB_VMODE_YWRAP;
498                 var->xoffset = info->var.xoffset;
499                 var->yoffset = info->var.yoffset;
500         }
501
502         /* Virtual screen and panning are not supported */
503         if (var->xres_virtual > var->xres || var->yres_virtual > var->yres ||
504             var->xoffset || var->yoffset) {
505                 dev_dbg(info->device,
506                         "Virtual screen and panning are not supported\n");
507                 return -EINVAL;
508         }
509
510         var->xres_virtual = var->xres;
511         var->yres_virtual = var->yres;
512
513         /* We support ARGB8888 only */
514         if (var->bits_per_pixel > 32 || var->grayscale ||
515             var->red.offset > 16 || var->green.offset > 8 ||
516             var->blue.offset > 0 || var->transp.offset > 24 ||
517             var->red.length > 8 || var->green.length > 8 ||
518             var->blue.length > 8 || var->transp.length > 8 ||
519             var->red.msb_right || var->green.msb_right ||
520             var->blue.msb_right || var->transp.msb_right || var->nonstd) {
521                 dev_dbg(info->device, "We support ARGB8888 only\n");
522                 return -EINVAL;
523         }
524
525         var->bits_per_pixel = 32;
526         var->red.offset = 16;
527         var->green.offset = 8;
528         var->blue.offset = 0;
529         var->transp.offset = 24;
530         var->red.length = 8;
531         var->green.length = 8;
532         var->blue.length = 8;
533         var->transp.length = 8;
534         var->red.msb_right = 0;
535         var->green.msb_right = 0;
536         var->blue.msb_right = 0;
537         var->transp.msb_right = 0;
538
539         /* Rotation is not supported */
540         if (var->rotate) {
541                 dev_dbg(info->device, "Rotation is not supported\n");
542                 return -EINVAL;
543         }
544
545         /* Memory limit */
546         if (var->yres * line_length > ps3fb.xdr_size) {
547                 dev_dbg(info->device, "Not enough memory\n");
548                 return -ENOMEM;
549         }
550
551         var->height = -1;
552         var->width = -1;
553
554         return 0;
555 }
556
557     /*
558      * This routine actually sets the video mode.
559      */
560
561 static int ps3fb_set_par(struct fb_info *info)
562 {
563         struct ps3fb_par *par = info->par;
564         unsigned int mode, lines, maxlines;
565         int i;
566         unsigned long offset, dst;
567
568         dev_dbg(info->device, "xres:%d xv:%d yres:%d yv:%d clock:%d\n",
569                 info->var.xres, info->var.xres_virtual,
570                 info->var.yres, info->var.yres_virtual, info->var.pixclock);
571
572         mode = ps3fb_find_mode(&info->var, &info->fix.line_length);
573         if (!mode)
574                 return -EINVAL;
575
576         i = ps3fb_get_res_table(info->var.xres, info->var.yres, mode);
577         par->res_index = i;
578
579         info->fix.smem_start = virt_to_abs(ps3fb.xdr_ea);
580         info->fix.smem_len = ps3fb.xdr_size;
581         info->screen_base = (char __iomem *)ps3fb.xdr_ea;
582
583         par->num_frames = info->fix.smem_len/
584                           (ps3fb_res[i].xres*ps3fb_res[i].yres*BPP);
585
586         /* Keep the special bits we cannot set using fb_var_screeninfo */
587         par->new_mode_id = (par->new_mode_id & ~PS3AV_MODE_MASK) | mode;
588
589         par->width = info->var.xres;
590         par->height = info->var.yres;
591         offset = VP_OFF(i);
592         par->fb_offset = GPU_ALIGN_UP(offset);
593         par->full_offset = par->fb_offset - offset;
594
595         if (par->new_mode_id != par->mode_id) {
596                 if (ps3av_set_video_mode(par->new_mode_id)) {
597                         par->new_mode_id = par->mode_id;
598                         return -EINVAL;
599                 }
600                 par->mode_id = par->new_mode_id;
601         }
602
603         /* Clear XDR frame buffer memory */
604         memset(ps3fb.xdr_ea, 0, ps3fb.xdr_size);
605
606         /* Clear DDR frame buffer memory */
607         lines = ps3fb_res[i].yres * par->num_frames;
608         if (par->full_offset)
609                 lines++;
610         maxlines = ps3fb.xdr_size / info->fix.line_length;
611         for (dst = 0; lines; dst += maxlines * info->fix.line_length) {
612                 unsigned int l = min(lines, maxlines);
613                 ps3fb_sync_image(info->device, 0, dst, 0, ps3fb_res[i].xres, l,
614                                  info->fix.line_length);
615                 lines -= l;
616         }
617
618         return 0;
619 }
620
621     /*
622      *  Set a single color register. The values supplied are already
623      *  rounded down to the hardware's capabilities (according to the
624      *  entries in the var structure). Return != 0 for invalid regno.
625      */
626
627 static int ps3fb_setcolreg(unsigned int regno, unsigned int red,
628                            unsigned int green, unsigned int blue,
629                            unsigned int transp, struct fb_info *info)
630 {
631         if (regno >= 16)
632                 return 1;
633
634         red >>= 8;
635         green >>= 8;
636         blue >>= 8;
637         transp >>= 8;
638
639         ((u32 *)info->pseudo_palette)[regno] = transp << 24 | red << 16 |
640                                                green << 8 | blue;
641         return 0;
642 }
643
644     /*
645      *  As we have a virtual frame buffer, we need our own mmap function
646      */
647
648 static int ps3fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
649 {
650         unsigned long size, offset;
651
652         size = vma->vm_end - vma->vm_start;
653         offset = vma->vm_pgoff << PAGE_SHIFT;
654         if (offset + size > info->fix.smem_len)
655                 return -EINVAL;
656
657         offset += info->fix.smem_start;
658         if (remap_pfn_range(vma, vma->vm_start, offset >> PAGE_SHIFT,
659                             size, vma->vm_page_prot))
660                 return -EAGAIN;
661
662         dev_dbg(info->device, "ps3fb: mmap framebuffer P(%lx)->V(%lx)\n",
663                 offset, vma->vm_start);
664         return 0;
665 }
666
667     /*
668      * Blank the display
669      */
670
671 static int ps3fb_blank(int blank, struct fb_info *info)
672 {
673         int retval;
674
675         dev_dbg(info->device, "%s: blank:%d\n", __func__, blank);
676         switch (blank) {
677         case FB_BLANK_POWERDOWN:
678         case FB_BLANK_HSYNC_SUSPEND:
679         case FB_BLANK_VSYNC_SUSPEND:
680         case FB_BLANK_NORMAL:
681                 retval = ps3av_video_mute(1);   /* mute on */
682                 if (!retval)
683                         ps3fb.is_blanked = 1;
684                 break;
685
686         default:                /* unblank */
687                 retval = ps3av_video_mute(0);   /* mute off */
688                 if (!retval)
689                         ps3fb.is_blanked = 0;
690                 break;
691         }
692         return retval;
693 }
694
695 static int ps3fb_get_vblank(struct fb_vblank *vblank)
696 {
697         memset(vblank, 0, sizeof(&vblank));
698         vblank->flags = FB_VBLANK_HAVE_VSYNC;
699         return 0;
700 }
701
702 static int ps3fb_wait_for_vsync(u32 crtc)
703 {
704         int ret;
705         u64 count;
706
707         count = ps3fb.vblank_count;
708         ret = wait_event_interruptible_timeout(ps3fb.wait_vsync,
709                                                count != ps3fb.vblank_count,
710                                                HZ / 10);
711         if (!ret)
712                 return -ETIMEDOUT;
713
714         return 0;
715 }
716
717 static void ps3fb_flip_ctl(int on, void *data)
718 {
719         struct ps3fb_priv *priv = data;
720         if (on)
721                 atomic_dec_if_positive(&priv->ext_flip);
722         else
723                 atomic_inc(&priv->ext_flip);
724 }
725
726
727     /*
728      * ioctl
729      */
730
731 static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
732                        unsigned long arg)
733 {
734         void __user *argp = (void __user *)arg;
735         u32 val;
736         int retval = -EFAULT;
737
738         switch (cmd) {
739         case FBIOGET_VBLANK:
740                 {
741                         struct fb_vblank vblank;
742                         dev_dbg(info->device, "FBIOGET_VBLANK:\n");
743                         retval = ps3fb_get_vblank(&vblank);
744                         if (retval)
745                                 break;
746
747                         if (copy_to_user(argp, &vblank, sizeof(vblank)))
748                                 retval = -EFAULT;
749                         break;
750                 }
751
752         case FBIO_WAITFORVSYNC:
753                 {
754                         u32 crt;
755                         dev_dbg(info->device, "FBIO_WAITFORVSYNC:\n");
756                         if (get_user(crt, (u32 __user *) arg))
757                                 break;
758
759                         retval = ps3fb_wait_for_vsync(crt);
760                         break;
761                 }
762
763         case PS3FB_IOCTL_SETMODE:
764                 {
765                         struct ps3fb_par *par = info->par;
766                         const struct fb_videomode *mode;
767                         struct fb_var_screeninfo var;
768
769                         if (copy_from_user(&val, argp, sizeof(val)))
770                                 break;
771
772                         if (!(val & PS3AV_MODE_MASK)) {
773                                 u32 id = ps3av_get_auto_mode();
774                                 if (id > 0)
775                                         val = (val & ~PS3AV_MODE_MASK) | id;
776                         }
777                         dev_dbg(info->device, "PS3FB_IOCTL_SETMODE:%x\n", val);
778                         retval = -EINVAL;
779                         mode = ps3fb_default_mode(val);
780                         if (mode) {
781                                 var = info->var;
782                                 fb_videomode_to_var(&var, mode);
783                                 acquire_console_sem();
784                                 info->flags |= FBINFO_MISC_USEREVENT;
785                                 /* Force, in case only special bits changed */
786                                 var.activate |= FB_ACTIVATE_FORCE;
787                                 par->new_mode_id = val;
788                                 retval = fb_set_var(info, &var);
789                                 info->flags &= ~FBINFO_MISC_USEREVENT;
790                                 release_console_sem();
791                         }
792                         break;
793                 }
794
795         case PS3FB_IOCTL_GETMODE:
796                 val = ps3av_get_mode();
797                 dev_dbg(info->device, "PS3FB_IOCTL_GETMODE:%x\n", val);
798                 if (!copy_to_user(argp, &val, sizeof(val)))
799                         retval = 0;
800                 break;
801
802         case PS3FB_IOCTL_SCREENINFO:
803                 {
804                         struct ps3fb_par *par = info->par;
805                         struct ps3fb_ioctl_res res;
806                         int i = par->res_index;
807                         dev_dbg(info->device, "PS3FB_IOCTL_SCREENINFO:\n");
808                         res.xres = ps3fb_res[i].xres;
809                         res.yres = ps3fb_res[i].yres;
810                         res.xoff = ps3fb_res[i].xoff;
811                         res.yoff = ps3fb_res[i].yoff;
812                         res.num_frames = par->num_frames;
813                         if (!copy_to_user(argp, &res, sizeof(res)))
814                                 retval = 0;
815                         break;
816                 }
817
818         case PS3FB_IOCTL_ON:
819                 dev_dbg(info->device, "PS3FB_IOCTL_ON:\n");
820                 atomic_inc(&ps3fb.ext_flip);
821                 retval = 0;
822                 break;
823
824         case PS3FB_IOCTL_OFF:
825                 dev_dbg(info->device, "PS3FB_IOCTL_OFF:\n");
826                 atomic_dec_if_positive(&ps3fb.ext_flip);
827                 retval = 0;
828                 break;
829
830         case PS3FB_IOCTL_FSEL:
831                 if (copy_from_user(&val, argp, sizeof(val)))
832                         break;
833
834                 dev_dbg(info->device, "PS3FB_IOCTL_FSEL:%d\n", val);
835                 retval = ps3fb_sync(info, val);
836                 break;
837
838         default:
839                 retval = -ENOIOCTLCMD;
840                 break;
841         }
842         return retval;
843 }
844
845 static int ps3fbd(void *arg)
846 {
847         struct fb_info *info = arg;
848
849         set_freezable();
850         while (!kthread_should_stop()) {
851                 try_to_freeze();
852                 set_current_state(TASK_INTERRUPTIBLE);
853                 if (ps3fb.is_kicked) {
854                         ps3fb.is_kicked = 0;
855                         ps3fb_sync(info, 0);    /* single buffer */
856                 }
857                 schedule();
858         }
859         return 0;
860 }
861
862 static irqreturn_t ps3fb_vsync_interrupt(int irq, void *ptr)
863 {
864         struct device *dev = ptr;
865         u64 v1;
866         int status;
867         struct display_head *head = &ps3fb.dinfo->display_head[1];
868
869         status = lv1_gpu_context_intr(ps3fb.context_handle, &v1);
870         if (status) {
871                 dev_err(dev, "%s: lv1_gpu_context_intr failed: %d\n", __func__,
872                         status);
873                 return IRQ_NONE;
874         }
875
876         if (v1 & (1 << GPU_INTR_STATUS_VSYNC_1)) {
877                 /* VSYNC */
878                 ps3fb.vblank_count = head->vblank_count;
879                 if (ps3fb.task && !ps3fb.is_blanked &&
880                     !atomic_read(&ps3fb.ext_flip)) {
881                         ps3fb.is_kicked = 1;
882                         wake_up_process(ps3fb.task);
883                 }
884                 wake_up_interruptible(&ps3fb.wait_vsync);
885         }
886
887         return IRQ_HANDLED;
888 }
889
890
891 static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo,
892                                 struct device *dev)
893 {
894         int error;
895
896         dev_dbg(dev, "version_driver:%x\n", dinfo->version_driver);
897         dev_dbg(dev, "irq outlet:%x\n", dinfo->irq.irq_outlet);
898         dev_dbg(dev,
899                 "version_gpu: %x memory_size: %x ch: %x core_freq: %d "
900                 "mem_freq:%d\n",
901                 dinfo->version_gpu, dinfo->memory_size, dinfo->hardware_channel,
902                 dinfo->nvcore_frequency/1000000, dinfo->memory_frequency/1000000);
903
904         if (dinfo->version_driver != GPU_DRIVER_INFO_VERSION) {
905                 dev_err(dev, "%s: version_driver err:%x\n", __func__,
906                         dinfo->version_driver);
907                 return -EINVAL;
908         }
909
910         error = ps3_irq_plug_setup(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet,
911                                    &ps3fb.irq_no);
912         if (error) {
913                 dev_err(dev, "%s: ps3_alloc_irq failed %d\n", __func__, error);
914                 return error;
915         }
916
917         error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED,
918                             DEVICE_NAME, dev);
919         if (error) {
920                 dev_err(dev, "%s: request_irq failed %d\n", __func__, error);
921                 ps3_irq_plug_destroy(ps3fb.irq_no);
922                 return error;
923         }
924
925         dinfo->irq.mask = (1 << GPU_INTR_STATUS_VSYNC_1) |
926                           (1 << GPU_INTR_STATUS_FLIP_1);
927         return 0;
928 }
929
930 static int ps3fb_xdr_settings(u64 xdr_lpar, struct device *dev)
931 {
932         int status;
933
934         status = lv1_gpu_context_iomap(ps3fb.context_handle, GPU_IOIF,
935                                        xdr_lpar, ps3fb_videomemory.size, 0);
936         if (status) {
937                 dev_err(dev, "%s: lv1_gpu_context_iomap failed: %d\n",
938                         __func__, status);
939                 return -ENXIO;
940         }
941         dev_dbg(dev,
942                 "video:%p xdr_ea:%p ioif:%lx lpar:%lx phys:%lx size:%lx\n",
943                 ps3fb_videomemory.address, ps3fb.xdr_ea, GPU_IOIF, xdr_lpar,
944                 virt_to_abs(ps3fb.xdr_ea), ps3fb_videomemory.size);
945
946         status = lv1_gpu_context_attribute(ps3fb.context_handle,
947                                            L1GPU_CONTEXT_ATTRIBUTE_FB_SETUP,
948                                            xdr_lpar + ps3fb.xdr_size,
949                                            GPU_CMD_BUF_SIZE,
950                                            GPU_IOIF + ps3fb.xdr_size, 0);
951         if (status) {
952                 dev_err(dev,
953                         "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n",
954                         __func__, status);
955                 return -ENXIO;
956         }
957         return 0;
958 }
959
960 static struct fb_ops ps3fb_ops = {
961         .fb_open        = ps3fb_open,
962         .fb_release     = ps3fb_release,
963         .fb_read        = fb_sys_read,
964         .fb_write       = fb_sys_write,
965         .fb_check_var   = ps3fb_check_var,
966         .fb_set_par     = ps3fb_set_par,
967         .fb_setcolreg   = ps3fb_setcolreg,
968         .fb_fillrect    = sys_fillrect,
969         .fb_copyarea    = sys_copyarea,
970         .fb_imageblit   = sys_imageblit,
971         .fb_mmap        = ps3fb_mmap,
972         .fb_blank       = ps3fb_blank,
973         .fb_ioctl       = ps3fb_ioctl,
974         .fb_compat_ioctl = ps3fb_ioctl
975 };
976
977 static struct fb_fix_screeninfo ps3fb_fix __initdata = {
978         .id =           DEVICE_NAME,
979         .type =         FB_TYPE_PACKED_PIXELS,
980         .visual =       FB_VISUAL_TRUECOLOR,
981         .accel =        FB_ACCEL_NONE,
982 };
983
984 static int ps3fb_set_sync(struct device *dev)
985 {
986         int status;
987
988 #ifdef HEAD_A
989         status = lv1_gpu_context_attribute(0x0,
990                                            L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
991                                            0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0);
992         if (status) {
993                 dev_err(dev,
994                         "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: "
995                         "%d\n",
996                         __func__, status);
997                 return -1;
998         }
999 #endif
1000 #ifdef HEAD_B
1001         status = lv1_gpu_context_attribute(0x0,
1002                                            L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
1003                                            1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0);
1004
1005         if (status) {
1006                 dev_err(dev,
1007                         "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: "
1008                         "%d\n",
1009                         __func__, status);
1010                 return -1;
1011         }
1012 #endif
1013         return 0;
1014 }
1015
1016 static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
1017 {
1018         struct fb_info *info;
1019         struct ps3fb_par *par;
1020         int retval = -ENOMEM;
1021         u32 xres, yres;
1022         u64 ddr_lpar = 0;
1023         u64 lpar_dma_control = 0;
1024         u64 lpar_driver_info = 0;
1025         u64 lpar_reports = 0;
1026         u64 lpar_reports_size = 0;
1027         u64 xdr_lpar;
1028         int status, res_index;
1029         struct task_struct *task;
1030
1031         status = ps3_open_hv_device(dev);
1032         if (status) {
1033                 dev_err(&dev->core, "%s: ps3_open_hv_device failed\n",
1034                         __func__);
1035                 goto err;
1036         }
1037
1038         if (!ps3fb_mode)
1039                 ps3fb_mode = ps3av_get_mode();
1040         dev_dbg(&dev->core, "ps3av_mode:%d\n", ps3fb_mode);
1041
1042         if (ps3fb_mode > 0 &&
1043             !ps3av_video_mode2res(ps3fb_mode, &xres, &yres)) {
1044                 res_index = ps3fb_get_res_table(xres, yres, ps3fb_mode);
1045                 dev_dbg(&dev->core, "res_index:%d\n", res_index);
1046         } else
1047                 res_index = GPU_RES_INDEX;
1048
1049         atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */
1050         atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */
1051         init_waitqueue_head(&ps3fb.wait_vsync);
1052
1053         ps3fb_set_sync(&dev->core);
1054
1055         /* get gpu context handle */
1056         status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0,
1057                                          &ps3fb.memory_handle, &ddr_lpar);
1058         if (status) {
1059                 dev_err(&dev->core, "%s: lv1_gpu_memory_allocate failed: %d\n",
1060                         __func__, status);
1061                 goto err;
1062         }
1063         dev_dbg(&dev->core, "ddr:lpar:0x%lx\n", ddr_lpar);
1064
1065         status = lv1_gpu_context_allocate(ps3fb.memory_handle, 0,
1066                                           &ps3fb.context_handle,
1067                                           &lpar_dma_control, &lpar_driver_info,
1068                                           &lpar_reports, &lpar_reports_size);
1069         if (status) {
1070                 dev_err(&dev->core,
1071                         "%s: lv1_gpu_context_attribute failed: %d\n", __func__,
1072                         status);
1073                 goto err_gpu_memory_free;
1074         }
1075
1076         /* vsync interrupt */
1077         ps3fb.dinfo = ioremap(lpar_driver_info, 128 * 1024);
1078         if (!ps3fb.dinfo) {
1079                 dev_err(&dev->core, "%s: ioremap failed\n", __func__);
1080                 goto err_gpu_context_free;
1081         }
1082
1083         retval = ps3fb_vsync_settings(ps3fb.dinfo, &dev->core);
1084         if (retval)
1085                 goto err_iounmap_dinfo;
1086
1087         /* XDR frame buffer */
1088         ps3fb.xdr_ea = ps3fb_videomemory.address;
1089         xdr_lpar = ps3_mm_phys_to_lpar(__pa(ps3fb.xdr_ea));
1090
1091         /* Clear memory to prevent kernel info leakage into userspace */
1092         memset(ps3fb.xdr_ea, 0, ps3fb_videomemory.size);
1093
1094         /* The GPU command buffer is at the end of video memory */
1095         ps3fb.xdr_size = ps3fb_videomemory.size - GPU_CMD_BUF_SIZE;
1096
1097         retval = ps3fb_xdr_settings(xdr_lpar, &dev->core);
1098         if (retval)
1099                 goto err_free_irq;
1100
1101         info = framebuffer_alloc(sizeof(struct ps3fb_par), &dev->core);
1102         if (!info)
1103                 goto err_free_irq;
1104
1105         par = info->par;
1106         par->mode_id = ~ps3fb_mode;     /* != ps3fb_mode, to trigger change */
1107         par->new_mode_id = ps3fb_mode;
1108         par->res_index = res_index;
1109         par->num_frames = 1;
1110
1111         info->screen_base = (char __iomem *)ps3fb.xdr_ea;
1112         info->fbops = &ps3fb_ops;
1113
1114         info->fix = ps3fb_fix;
1115         info->fix.smem_start = virt_to_abs(ps3fb.xdr_ea);
1116         info->fix.smem_len = ps3fb.xdr_size;
1117         info->pseudo_palette = par->pseudo_palette;
1118         info->flags = FBINFO_DEFAULT | FBINFO_READS_FAST;
1119
1120         retval = fb_alloc_cmap(&info->cmap, 256, 0);
1121         if (retval < 0)
1122                 goto err_framebuffer_release;
1123
1124         if (!fb_find_mode(&info->var, info, mode_option, ps3fb_modedb,
1125                           ARRAY_SIZE(ps3fb_modedb),
1126                           ps3fb_default_mode(par->new_mode_id), 32)) {
1127                 retval = -EINVAL;
1128                 goto err_fb_dealloc;
1129         }
1130
1131         fb_videomode_to_modelist(ps3fb_modedb, ARRAY_SIZE(ps3fb_modedb),
1132                                  &info->modelist);
1133
1134         retval = register_framebuffer(info);
1135         if (retval < 0)
1136                 goto err_fb_dealloc;
1137
1138         dev->core.driver_data = info;
1139
1140         dev_info(info->device, "%s %s, using %lu KiB of video memory\n",
1141                  dev_driver_string(info->dev), info->dev->bus_id,
1142                  ps3fb.xdr_size >> 10);
1143
1144         task = kthread_run(ps3fbd, info, DEVICE_NAME);
1145         if (IS_ERR(task)) {
1146                 retval = PTR_ERR(task);
1147                 goto err_unregister_framebuffer;
1148         }
1149
1150         ps3fb.task = task;
1151         ps3av_register_flip_ctl(ps3fb_flip_ctl, &ps3fb);
1152
1153         return 0;
1154
1155 err_unregister_framebuffer:
1156         unregister_framebuffer(info);
1157 err_fb_dealloc:
1158         fb_dealloc_cmap(&info->cmap);
1159 err_framebuffer_release:
1160         framebuffer_release(info);
1161 err_free_irq:
1162         free_irq(ps3fb.irq_no, dev);
1163         ps3_irq_plug_destroy(ps3fb.irq_no);
1164 err_iounmap_dinfo:
1165         iounmap((u8 __iomem *)ps3fb.dinfo);
1166 err_gpu_context_free:
1167         lv1_gpu_context_free(ps3fb.context_handle);
1168 err_gpu_memory_free:
1169         lv1_gpu_memory_free(ps3fb.memory_handle);
1170 err:
1171         return retval;
1172 }
1173
1174 static int ps3fb_shutdown(struct ps3_system_bus_device *dev)
1175 {
1176         int status;
1177         struct fb_info *info = dev->core.driver_data;
1178
1179         dev_dbg(&dev->core, " -> %s:%d\n", __func__, __LINE__);
1180
1181         ps3fb_flip_ctl(0, &ps3fb);      /* flip off */
1182         ps3fb.dinfo->irq.mask = 0;
1183
1184         if (info) {
1185                 unregister_framebuffer(info);
1186                 fb_dealloc_cmap(&info->cmap);
1187                 framebuffer_release(info);
1188         }
1189
1190         ps3av_register_flip_ctl(NULL, NULL);
1191         if (ps3fb.task) {
1192                 struct task_struct *task = ps3fb.task;
1193                 ps3fb.task = NULL;
1194                 kthread_stop(task);
1195         }
1196         if (ps3fb.irq_no) {
1197                 free_irq(ps3fb.irq_no, dev);
1198                 ps3_irq_plug_destroy(ps3fb.irq_no);
1199         }
1200         iounmap((u8 __iomem *)ps3fb.dinfo);
1201
1202         status = lv1_gpu_context_free(ps3fb.context_handle);
1203         if (status)
1204                 dev_dbg(&dev->core, "lv1_gpu_context_free failed: %d\n",
1205                         status);
1206
1207         status = lv1_gpu_memory_free(ps3fb.memory_handle);
1208         if (status)
1209                 dev_dbg(&dev->core, "lv1_gpu_memory_free failed: %d\n",
1210                         status);
1211
1212         ps3_close_hv_device(dev);
1213         dev_dbg(&dev->core, " <- %s:%d\n", __func__, __LINE__);
1214
1215         return 0;
1216 }
1217
1218 static struct ps3_system_bus_driver ps3fb_driver = {
1219         .match_id       = PS3_MATCH_ID_GRAPHICS,
1220         .core.name      = DEVICE_NAME,
1221         .core.owner     = THIS_MODULE,
1222         .probe          = ps3fb_probe,
1223         .remove         = ps3fb_shutdown,
1224         .shutdown       = ps3fb_shutdown,
1225 };
1226
1227 static int __init ps3fb_setup(void)
1228 {
1229         char *options;
1230
1231 #ifdef MODULE
1232         return 0;
1233 #endif
1234
1235         if (fb_get_options(DEVICE_NAME, &options))
1236                 return -ENXIO;
1237
1238         if (!options || !*options)
1239                 return 0;
1240
1241         while (1) {
1242                 char *this_opt = strsep(&options, ",");
1243
1244                 if (!this_opt)
1245                         break;
1246                 if (!*this_opt)
1247                         continue;
1248                 if (!strncmp(this_opt, "mode:", 5))
1249                         ps3fb_mode = simple_strtoul(this_opt + 5, NULL, 0);
1250                 else
1251                         mode_option = this_opt;
1252         }
1253         return 0;
1254 }
1255
1256 static int __init ps3fb_init(void)
1257 {
1258         if (!ps3fb_videomemory.address ||  ps3fb_setup())
1259                 return -ENXIO;
1260
1261         return ps3_system_bus_driver_register(&ps3fb_driver);
1262 }
1263
1264 static void __exit ps3fb_exit(void)
1265 {
1266         pr_debug(" -> %s:%d\n", __func__, __LINE__);
1267         ps3_system_bus_driver_unregister(&ps3fb_driver);
1268         pr_debug(" <- %s:%d\n", __func__, __LINE__);
1269 }
1270
1271 module_init(ps3fb_init);
1272 module_exit(ps3fb_exit);
1273
1274 MODULE_LICENSE("GPL");
1275 MODULE_DESCRIPTION("PS3 GPU Frame Buffer Driver");
1276 MODULE_AUTHOR("Sony Computer Entertainment Inc.");
1277 MODULE_ALIAS(PS3_MODULE_ALIAS_GRAPHICS);