diff options
Diffstat (limited to 'drivers/video/ps3fb.c')
-rw-r--r-- | drivers/video/ps3fb.c | 301 |
1 files changed, 134 insertions, 167 deletions
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c index 9756a728b74f..646ec823c168 100644 --- a/drivers/video/ps3fb.c +++ b/drivers/video/ps3fb.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/platform_device.h> | ||
31 | #include <linux/console.h> | 30 | #include <linux/console.h> |
32 | #include <linux/ioctl.h> | 31 | #include <linux/ioctl.h> |
33 | #include <linux/notifier.h> | 32 | #include <linux/notifier.h> |
@@ -46,6 +45,9 @@ | |||
46 | #include <asm/ps3fb.h> | 45 | #include <asm/ps3fb.h> |
47 | #include <asm/ps3.h> | 46 | #include <asm/ps3.h> |
48 | 47 | ||
48 | |||
49 | #define DEVICE_NAME "ps3fb" | ||
50 | |||
49 | #ifdef PS3FB_DEBUG | 51 | #ifdef PS3FB_DEBUG |
50 | #define DPRINTK(fmt, args...) printk("%s: " fmt, __func__ , ##args) | 52 | #define DPRINTK(fmt, args...) printk("%s: " fmt, __func__ , ##args) |
51 | #else | 53 | #else |
@@ -126,7 +128,6 @@ struct gpu_driver_info { | |||
126 | 128 | ||
127 | struct ps3fb_priv { | 129 | struct ps3fb_priv { |
128 | unsigned int irq_no; | 130 | unsigned int irq_no; |
129 | void *dev; | ||
130 | 131 | ||
131 | u64 context_handle, memory_handle; | 132 | u64 context_handle, memory_handle; |
132 | void *xdr_ea; | 133 | void *xdr_ea; |
@@ -171,7 +172,7 @@ static const struct ps3fb_res_table ps3fb_res[] = { | |||
171 | { 0, 0, 0, 0 , 0} }; | 172 | { 0, 0, 0, 0 , 0} }; |
172 | 173 | ||
173 | /* default resolution */ | 174 | /* default resolution */ |
174 | #define GPU_RES_INDEX 0 /* 720 x 480 */ | 175 | #define GPU_RES_INDEX 0 /* 720 x 480 */ |
175 | 176 | ||
176 | static const struct fb_videomode ps3fb_modedb[] = { | 177 | static const struct fb_videomode ps3fb_modedb[] = { |
177 | /* 60 Hz broadcast modes (modes "1" to "5") */ | 178 | /* 60 Hz broadcast modes (modes "1" to "5") */ |
@@ -298,10 +299,9 @@ static const struct fb_videomode ps3fb_modedb[] = { | |||
298 | #define FB_OFF(i) (GPU_OFFSET - VP_OFF(i) % GPU_OFFSET) | 299 | #define FB_OFF(i) (GPU_OFFSET - VP_OFF(i) % GPU_OFFSET) |
299 | 300 | ||
300 | static int ps3fb_mode; | 301 | static int ps3fb_mode; |
301 | module_param(ps3fb_mode, bool, 0); | 302 | module_param(ps3fb_mode, int, 0); |
302 | |||
303 | static char *mode_option __initdata; | ||
304 | 303 | ||
304 | static char *mode_option __devinitdata; | ||
305 | 305 | ||
306 | static int ps3fb_get_res_table(u32 xres, u32 yres) | 306 | static int ps3fb_get_res_table(u32 xres, u32 yres) |
307 | { | 307 | { |
@@ -681,15 +681,15 @@ int ps3fb_wait_for_vsync(u32 crtc) | |||
681 | 681 | ||
682 | EXPORT_SYMBOL_GPL(ps3fb_wait_for_vsync); | 682 | EXPORT_SYMBOL_GPL(ps3fb_wait_for_vsync); |
683 | 683 | ||
684 | void ps3fb_flip_ctl(int on) | 684 | void ps3fb_flip_ctl(int on, void *data) |
685 | { | 685 | { |
686 | struct ps3fb_priv *priv = data; | ||
686 | if (on) | 687 | if (on) |
687 | atomic_dec_if_positive(&ps3fb.ext_flip); | 688 | atomic_dec_if_positive(&priv->ext_flip); |
688 | else | 689 | else |
689 | atomic_inc(&ps3fb.ext_flip); | 690 | atomic_inc(&priv->ext_flip); |
690 | } | 691 | } |
691 | 692 | ||
692 | EXPORT_SYMBOL_GPL(ps3fb_flip_ctl); | ||
693 | 693 | ||
694 | /* | 694 | /* |
695 | * ioctl | 695 | * ioctl |
@@ -812,6 +812,7 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd, | |||
812 | 812 | ||
813 | static int ps3fbd(void *arg) | 813 | static int ps3fbd(void *arg) |
814 | { | 814 | { |
815 | set_freezable(); | ||
815 | while (!kthread_should_stop()) { | 816 | while (!kthread_should_stop()) { |
816 | try_to_freeze(); | 817 | try_to_freeze(); |
817 | set_current_state(TASK_INTERRUPTIBLE); | 818 | set_current_state(TASK_INTERRUPTIBLE); |
@@ -851,37 +852,9 @@ static irqreturn_t ps3fb_vsync_interrupt(int irq, void *ptr) | |||
851 | return IRQ_HANDLED; | 852 | return IRQ_HANDLED; |
852 | } | 853 | } |
853 | 854 | ||
854 | #ifndef MODULE | ||
855 | static int __init ps3fb_setup(char *options) | ||
856 | { | ||
857 | char *this_opt; | ||
858 | int mode = 0; | ||
859 | |||
860 | if (!options || !*options) | ||
861 | return 0; /* no options */ | ||
862 | |||
863 | while ((this_opt = strsep(&options, ",")) != NULL) { | ||
864 | if (!*this_opt) | ||
865 | continue; | ||
866 | if (!strncmp(this_opt, "mode:", 5)) | ||
867 | mode = simple_strtoul(this_opt + 5, NULL, 0); | ||
868 | else | ||
869 | mode_option = this_opt; | ||
870 | } | ||
871 | return mode; | ||
872 | } | ||
873 | #endif /* MODULE */ | ||
874 | |||
875 | /* | ||
876 | * Initialisation | ||
877 | */ | ||
878 | 855 | ||
879 | static void ps3fb_platform_release(struct device *device) | 856 | static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, |
880 | { | 857 | struct ps3_system_bus_device *dev) |
881 | /* This is called when the reference count goes to zero. */ | ||
882 | } | ||
883 | |||
884 | static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev) | ||
885 | { | 858 | { |
886 | int error; | 859 | int error; |
887 | 860 | ||
@@ -897,7 +870,6 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev) | |||
897 | return -EINVAL; | 870 | return -EINVAL; |
898 | } | 871 | } |
899 | 872 | ||
900 | ps3fb.dev = dev; | ||
901 | error = ps3_irq_plug_setup(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet, | 873 | error = ps3_irq_plug_setup(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet, |
902 | &ps3fb.irq_no); | 874 | &ps3fb.irq_no); |
903 | if (error) { | 875 | if (error) { |
@@ -907,7 +879,7 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev) | |||
907 | } | 879 | } |
908 | 880 | ||
909 | error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED, | 881 | error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED, |
910 | "ps3fb vsync", ps3fb.dev); | 882 | DEVICE_NAME, dev); |
911 | if (error) { | 883 | if (error) { |
912 | printk(KERN_ERR "%s: request_irq failed %d\n", __func__, | 884 | printk(KERN_ERR "%s: request_irq failed %d\n", __func__, |
913 | error); | 885 | error); |
@@ -951,12 +923,14 @@ static int ps3fb_xdr_settings(u64 xdr_lpar) | |||
951 | static struct fb_ops ps3fb_ops = { | 923 | static struct fb_ops ps3fb_ops = { |
952 | .fb_open = ps3fb_open, | 924 | .fb_open = ps3fb_open, |
953 | .fb_release = ps3fb_release, | 925 | .fb_release = ps3fb_release, |
926 | .fb_read = fb_sys_read, | ||
927 | .fb_write = fb_sys_write, | ||
954 | .fb_check_var = ps3fb_check_var, | 928 | .fb_check_var = ps3fb_check_var, |
955 | .fb_set_par = ps3fb_set_par, | 929 | .fb_set_par = ps3fb_set_par, |
956 | .fb_setcolreg = ps3fb_setcolreg, | 930 | .fb_setcolreg = ps3fb_setcolreg, |
957 | .fb_fillrect = cfb_fillrect, | 931 | .fb_fillrect = sys_fillrect, |
958 | .fb_copyarea = cfb_copyarea, | 932 | .fb_copyarea = sys_copyarea, |
959 | .fb_imageblit = cfb_imageblit, | 933 | .fb_imageblit = sys_imageblit, |
960 | .fb_mmap = ps3fb_mmap, | 934 | .fb_mmap = ps3fb_mmap, |
961 | .fb_blank = ps3fb_blank, | 935 | .fb_blank = ps3fb_blank, |
962 | .fb_ioctl = ps3fb_ioctl, | 936 | .fb_ioctl = ps3fb_ioctl, |
@@ -964,16 +938,45 @@ static struct fb_ops ps3fb_ops = { | |||
964 | }; | 938 | }; |
965 | 939 | ||
966 | static struct fb_fix_screeninfo ps3fb_fix __initdata = { | 940 | static struct fb_fix_screeninfo ps3fb_fix __initdata = { |
967 | .id = "PS3 FB", | 941 | .id = DEVICE_NAME, |
968 | .type = FB_TYPE_PACKED_PIXELS, | 942 | .type = FB_TYPE_PACKED_PIXELS, |
969 | .visual = FB_VISUAL_TRUECOLOR, | 943 | .visual = FB_VISUAL_TRUECOLOR, |
970 | .accel = FB_ACCEL_NONE, | 944 | .accel = FB_ACCEL_NONE, |
971 | }; | 945 | }; |
972 | 946 | ||
973 | static int __init ps3fb_probe(struct platform_device *dev) | 947 | static int ps3fb_set_sync(void) |
948 | { | ||
949 | int status; | ||
950 | |||
951 | #ifdef HEAD_A | ||
952 | status = lv1_gpu_context_attribute(0x0, | ||
953 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
954 | 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
955 | if (status) { | ||
956 | printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_SYNC " | ||
957 | "failed: %d\n", __func__, status); | ||
958 | return -1; | ||
959 | } | ||
960 | #endif | ||
961 | #ifdef HEAD_B | ||
962 | status = lv1_gpu_context_attribute(0x0, | ||
963 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
964 | 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
965 | |||
966 | if (status) { | ||
967 | printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_MODE " | ||
968 | "failed: %d\n", __func__, status); | ||
969 | return -1; | ||
970 | } | ||
971 | #endif | ||
972 | return 0; | ||
973 | } | ||
974 | |||
975 | static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev) | ||
974 | { | 976 | { |
975 | struct fb_info *info; | 977 | struct fb_info *info; |
976 | int retval = -ENOMEM; | 978 | int retval = -ENOMEM; |
979 | u32 xres, yres; | ||
977 | u64 ddr_lpar = 0; | 980 | u64 ddr_lpar = 0; |
978 | u64 lpar_dma_control = 0; | 981 | u64 lpar_dma_control = 0; |
979 | u64 lpar_driver_info = 0; | 982 | u64 lpar_driver_info = 0; |
@@ -984,6 +987,30 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
984 | unsigned long offset; | 987 | unsigned long offset; |
985 | struct task_struct *task; | 988 | struct task_struct *task; |
986 | 989 | ||
990 | status = ps3_open_hv_device(dev); | ||
991 | if (status) { | ||
992 | printk(KERN_ERR "%s: ps3_open_hv_device failed\n", __func__); | ||
993 | goto err; | ||
994 | } | ||
995 | |||
996 | if (!ps3fb_mode) | ||
997 | ps3fb_mode = ps3av_get_mode(); | ||
998 | DPRINTK("ps3av_mode:%d\n", ps3fb_mode); | ||
999 | |||
1000 | if (ps3fb_mode > 0 && | ||
1001 | !ps3av_video_mode2res(ps3fb_mode, &xres, &yres)) { | ||
1002 | ps3fb.res_index = ps3fb_get_res_table(xres, yres); | ||
1003 | DPRINTK("res_index:%d\n", ps3fb.res_index); | ||
1004 | } else | ||
1005 | ps3fb.res_index = GPU_RES_INDEX; | ||
1006 | |||
1007 | atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */ | ||
1008 | atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */ | ||
1009 | init_waitqueue_head(&ps3fb.wait_vsync); | ||
1010 | ps3fb.num_frames = 1; | ||
1011 | |||
1012 | ps3fb_set_sync(); | ||
1013 | |||
987 | /* get gpu context handle */ | 1014 | /* get gpu context handle */ |
988 | status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0, | 1015 | status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0, |
989 | &ps3fb.memory_handle, &ddr_lpar); | 1016 | &ps3fb.memory_handle, &ddr_lpar); |
@@ -1027,7 +1054,7 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
1027 | * leakage into userspace | 1054 | * leakage into userspace |
1028 | */ | 1055 | */ |
1029 | memset(ps3fb.xdr_ea, 0, ps3fb_videomemory.size); | 1056 | memset(ps3fb.xdr_ea, 0, ps3fb_videomemory.size); |
1030 | info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev); | 1057 | info = framebuffer_alloc(sizeof(u32) * 16, &dev->core); |
1031 | if (!info) | 1058 | if (!info) |
1032 | goto err_free_irq; | 1059 | goto err_free_irq; |
1033 | 1060 | ||
@@ -1040,7 +1067,7 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
1040 | info->fix.smem_len = ps3fb_videomemory.size - offset; | 1067 | info->fix.smem_len = ps3fb_videomemory.size - offset; |
1041 | info->pseudo_palette = info->par; | 1068 | info->pseudo_palette = info->par; |
1042 | info->par = NULL; | 1069 | info->par = NULL; |
1043 | info->flags = FBINFO_FLAG_DEFAULT; | 1070 | info->flags = FBINFO_DEFAULT | FBINFO_READS_FAST; |
1044 | 1071 | ||
1045 | retval = fb_alloc_cmap(&info->cmap, 256, 0); | 1072 | retval = fb_alloc_cmap(&info->cmap, 256, 0); |
1046 | if (retval < 0) | 1073 | if (retval < 0) |
@@ -1059,19 +1086,20 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
1059 | if (retval < 0) | 1086 | if (retval < 0) |
1060 | goto err_fb_dealloc; | 1087 | goto err_fb_dealloc; |
1061 | 1088 | ||
1062 | platform_set_drvdata(dev, info); | 1089 | dev->core.driver_data = info; |
1063 | 1090 | ||
1064 | printk(KERN_INFO | 1091 | printk(KERN_INFO |
1065 | "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n", | 1092 | "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n", |
1066 | info->node, ps3fb_videomemory.size >> 10); | 1093 | info->node, ps3fb_videomemory.size >> 10); |
1067 | 1094 | ||
1068 | task = kthread_run(ps3fbd, info, "ps3fbd"); | 1095 | task = kthread_run(ps3fbd, info, DEVICE_NAME); |
1069 | if (IS_ERR(task)) { | 1096 | if (IS_ERR(task)) { |
1070 | retval = PTR_ERR(task); | 1097 | retval = PTR_ERR(task); |
1071 | goto err_unregister_framebuffer; | 1098 | goto err_unregister_framebuffer; |
1072 | } | 1099 | } |
1073 | 1100 | ||
1074 | ps3fb.task = task; | 1101 | ps3fb.task = task; |
1102 | ps3av_register_flip_ctl(ps3fb_flip_ctl, &ps3fb); | ||
1075 | 1103 | ||
1076 | return 0; | 1104 | return 0; |
1077 | 1105 | ||
@@ -1082,7 +1110,7 @@ err_fb_dealloc: | |||
1082 | err_framebuffer_release: | 1110 | err_framebuffer_release: |
1083 | framebuffer_release(info); | 1111 | framebuffer_release(info); |
1084 | err_free_irq: | 1112 | err_free_irq: |
1085 | free_irq(ps3fb.irq_no, ps3fb.dev); | 1113 | free_irq(ps3fb.irq_no, dev); |
1086 | ps3_irq_plug_destroy(ps3fb.irq_no); | 1114 | ps3_irq_plug_destroy(ps3fb.irq_no); |
1087 | err_iounmap_dinfo: | 1115 | err_iounmap_dinfo: |
1088 | iounmap((u8 __iomem *)ps3fb.dinfo); | 1116 | iounmap((u8 __iomem *)ps3fb.dinfo); |
@@ -1094,26 +1122,30 @@ err: | |||
1094 | return retval; | 1122 | return retval; |
1095 | } | 1123 | } |
1096 | 1124 | ||
1097 | static void ps3fb_shutdown(struct platform_device *dev) | 1125 | static int ps3fb_shutdown(struct ps3_system_bus_device *dev) |
1098 | { | 1126 | { |
1099 | ps3fb_flip_ctl(0); /* flip off */ | 1127 | int status; |
1128 | struct fb_info *info = dev->core.driver_data; | ||
1129 | |||
1130 | DPRINTK(" -> %s:%d\n", __func__, __LINE__); | ||
1131 | |||
1132 | ps3fb_flip_ctl(0, &ps3fb); /* flip off */ | ||
1100 | ps3fb.dinfo->irq.mask = 0; | 1133 | ps3fb.dinfo->irq.mask = 0; |
1101 | free_irq(ps3fb.irq_no, ps3fb.dev); | ||
1102 | ps3_irq_plug_destroy(ps3fb.irq_no); | ||
1103 | iounmap((u8 __iomem *)ps3fb.dinfo); | ||
1104 | } | ||
1105 | 1134 | ||
1106 | void ps3fb_cleanup(void) | 1135 | if (info) { |
1107 | { | 1136 | unregister_framebuffer(info); |
1108 | int status; | 1137 | fb_dealloc_cmap(&info->cmap); |
1138 | framebuffer_release(info); | ||
1139 | } | ||
1109 | 1140 | ||
1141 | ps3av_register_flip_ctl(NULL, NULL); | ||
1110 | if (ps3fb.task) { | 1142 | if (ps3fb.task) { |
1111 | struct task_struct *task = ps3fb.task; | 1143 | struct task_struct *task = ps3fb.task; |
1112 | ps3fb.task = NULL; | 1144 | ps3fb.task = NULL; |
1113 | kthread_stop(task); | 1145 | kthread_stop(task); |
1114 | } | 1146 | } |
1115 | if (ps3fb.irq_no) { | 1147 | if (ps3fb.irq_no) { |
1116 | free_irq(ps3fb.irq_no, ps3fb.dev); | 1148 | free_irq(ps3fb.irq_no, dev); |
1117 | ps3_irq_plug_destroy(ps3fb.irq_no); | 1149 | ps3_irq_plug_destroy(ps3fb.irq_no); |
1118 | } | 1150 | } |
1119 | iounmap((u8 __iomem *)ps3fb.dinfo); | 1151 | iounmap((u8 __iomem *)ps3fb.dinfo); |
@@ -1126,134 +1158,69 @@ void ps3fb_cleanup(void) | |||
1126 | if (status) | 1158 | if (status) |
1127 | DPRINTK("lv1_gpu_memory_free failed: %d\n", status); | 1159 | DPRINTK("lv1_gpu_memory_free failed: %d\n", status); |
1128 | 1160 | ||
1129 | ps3av_dev_close(); | 1161 | ps3_close_hv_device(dev); |
1130 | } | 1162 | DPRINTK(" <- %s:%d\n", __func__, __LINE__); |
1131 | 1163 | ||
1132 | EXPORT_SYMBOL_GPL(ps3fb_cleanup); | ||
1133 | |||
1134 | static int ps3fb_remove(struct platform_device *dev) | ||
1135 | { | ||
1136 | struct fb_info *info = platform_get_drvdata(dev); | ||
1137 | |||
1138 | if (info) { | ||
1139 | unregister_framebuffer(info); | ||
1140 | fb_dealloc_cmap(&info->cmap); | ||
1141 | framebuffer_release(info); | ||
1142 | } | ||
1143 | ps3fb_cleanup(); | ||
1144 | return 0; | 1164 | return 0; |
1145 | } | 1165 | } |
1146 | 1166 | ||
1147 | static struct platform_driver ps3fb_driver = { | 1167 | static struct ps3_system_bus_driver ps3fb_driver = { |
1148 | .probe = ps3fb_probe, | 1168 | .match_id = PS3_MATCH_ID_GRAPHICS, |
1149 | .remove = ps3fb_remove, | 1169 | .core.name = DEVICE_NAME, |
1150 | .shutdown = ps3fb_shutdown, | 1170 | .core.owner = THIS_MODULE, |
1151 | .driver = { .name = "ps3fb" } | 1171 | .probe = ps3fb_probe, |
1152 | }; | 1172 | .remove = ps3fb_shutdown, |
1153 | 1173 | .shutdown = ps3fb_shutdown, | |
1154 | static struct platform_device ps3fb_device = { | ||
1155 | .name = "ps3fb", | ||
1156 | .id = 0, | ||
1157 | .dev = { .release = ps3fb_platform_release } | ||
1158 | }; | 1174 | }; |
1159 | 1175 | ||
1160 | int ps3fb_set_sync(void) | 1176 | static int __init ps3fb_setup(void) |
1161 | { | 1177 | { |
1162 | int status; | 1178 | char *options; |
1163 | 1179 | ||
1164 | #ifdef HEAD_A | 1180 | #ifdef MODULE |
1165 | status = lv1_gpu_context_attribute(0x0, | ||
1166 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
1167 | 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
1168 | if (status) { | ||
1169 | printk(KERN_ERR | ||
1170 | "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: %d\n", | ||
1171 | __func__, status); | ||
1172 | return -1; | ||
1173 | } | ||
1174 | #endif | ||
1175 | #ifdef HEAD_B | ||
1176 | status = lv1_gpu_context_attribute(0x0, | ||
1177 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
1178 | 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
1179 | |||
1180 | if (status) { | ||
1181 | printk(KERN_ERR | ||
1182 | "%s: lv1_gpu_context_attribute DISPLAY_MODE failed: %d\n", | ||
1183 | __func__, status); | ||
1184 | return -1; | ||
1185 | } | ||
1186 | #endif | ||
1187 | return 0; | 1181 | return 0; |
1188 | } | ||
1189 | |||
1190 | EXPORT_SYMBOL_GPL(ps3fb_set_sync); | ||
1191 | |||
1192 | static int __init ps3fb_init(void) | ||
1193 | { | ||
1194 | int error; | ||
1195 | #ifndef MODULE | ||
1196 | int mode; | ||
1197 | char *option = NULL; | ||
1198 | |||
1199 | if (fb_get_options("ps3fb", &option)) | ||
1200 | goto err; | ||
1201 | #endif | 1182 | #endif |
1202 | 1183 | ||
1203 | if (!ps3fb_videomemory.address) | 1184 | if (fb_get_options(DEVICE_NAME, &options)) |
1204 | goto err; | 1185 | return -ENXIO; |
1205 | |||
1206 | error = ps3av_dev_open(); | ||
1207 | if (error) { | ||
1208 | printk(KERN_ERR "%s: ps3av_dev_open failed\n", __func__); | ||
1209 | goto err; | ||
1210 | } | ||
1211 | 1186 | ||
1212 | ps3fb_mode = ps3av_get_mode(); | 1187 | if (!options || !*options) |
1213 | DPRINTK("ps3av_mode:%d\n", ps3fb_mode); | 1188 | return 0; |
1214 | #ifndef MODULE | ||
1215 | mode = ps3fb_setup(option); /* check boot option */ | ||
1216 | if (mode) | ||
1217 | ps3fb_mode = mode; | ||
1218 | #endif | ||
1219 | if (ps3fb_mode > 0) { | ||
1220 | u32 xres, yres; | ||
1221 | ps3av_video_mode2res(ps3fb_mode, &xres, &yres); | ||
1222 | ps3fb.res_index = ps3fb_get_res_table(xres, yres); | ||
1223 | DPRINTK("res_index:%d\n", ps3fb.res_index); | ||
1224 | } else | ||
1225 | ps3fb.res_index = GPU_RES_INDEX; | ||
1226 | 1189 | ||
1227 | atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */ | 1190 | while (1) { |
1228 | atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */ | 1191 | char *this_opt = strsep(&options, ","); |
1229 | init_waitqueue_head(&ps3fb.wait_vsync); | ||
1230 | ps3fb.num_frames = 1; | ||
1231 | 1192 | ||
1232 | error = platform_driver_register(&ps3fb_driver); | 1193 | if (!this_opt) |
1233 | if (!error) { | 1194 | break; |
1234 | error = platform_device_register(&ps3fb_device); | 1195 | if (!*this_opt) |
1235 | if (error) | 1196 | continue; |
1236 | platform_driver_unregister(&ps3fb_driver); | 1197 | if (!strncmp(this_opt, "mode:", 5)) |
1198 | ps3fb_mode = simple_strtoul(this_opt + 5, NULL, 0); | ||
1199 | else | ||
1200 | mode_option = this_opt; | ||
1237 | } | 1201 | } |
1202 | return 0; | ||
1203 | } | ||
1238 | 1204 | ||
1239 | ps3fb_set_sync(); | 1205 | static int __init ps3fb_init(void) |
1240 | 1206 | { | |
1241 | return error; | 1207 | if (!ps3fb_videomemory.address || ps3fb_setup()) |
1208 | return -ENXIO; | ||
1242 | 1209 | ||
1243 | err: | 1210 | return ps3_system_bus_driver_register(&ps3fb_driver); |
1244 | return -ENXIO; | ||
1245 | } | 1211 | } |
1246 | 1212 | ||
1247 | module_init(ps3fb_init); | ||
1248 | |||
1249 | #ifdef MODULE | ||
1250 | static void __exit ps3fb_exit(void) | 1213 | static void __exit ps3fb_exit(void) |
1251 | { | 1214 | { |
1252 | platform_device_unregister(&ps3fb_device); | 1215 | DPRINTK(" -> %s:%d\n", __func__, __LINE__); |
1253 | platform_driver_unregister(&ps3fb_driver); | 1216 | ps3_system_bus_driver_unregister(&ps3fb_driver); |
1217 | DPRINTK(" <- %s:%d\n", __func__, __LINE__); | ||
1254 | } | 1218 | } |
1255 | 1219 | ||
1220 | module_init(ps3fb_init); | ||
1256 | module_exit(ps3fb_exit); | 1221 | module_exit(ps3fb_exit); |
1257 | 1222 | ||
1258 | MODULE_LICENSE("GPL"); | 1223 | MODULE_LICENSE("GPL"); |
1259 | #endif /* MODULE */ | 1224 | MODULE_DESCRIPTION("PS3 GPU Frame Buffer Driver"); |
1225 | MODULE_AUTHOR("Sony Computer Entertainment Inc."); | ||
1226 | MODULE_ALIAS(PS3_MODULE_ALIAS_GRAPHICS); | ||