diff options
Diffstat (limited to 'drivers/video/ps3fb.c')
| -rw-r--r-- | drivers/video/ps3fb.c | 290 |
1 files changed, 127 insertions, 163 deletions
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c index 9cf92ba5d6e3..08b7ffbbbbd8 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 |
| @@ -851,37 +851,9 @@ static irqreturn_t ps3fb_vsync_interrupt(int irq, void *ptr) | |||
| 851 | return IRQ_HANDLED; | 851 | return IRQ_HANDLED; |
| 852 | } | 852 | } |
| 853 | 853 | ||
| 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 | 854 | ||
| 879 | static void ps3fb_platform_release(struct device *device) | 855 | static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, |
| 880 | { | 856 | 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 | { | 857 | { |
| 886 | int error; | 858 | int error; |
| 887 | 859 | ||
| @@ -897,7 +869,6 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev) | |||
| 897 | return -EINVAL; | 869 | return -EINVAL; |
| 898 | } | 870 | } |
| 899 | 871 | ||
| 900 | ps3fb.dev = dev; | ||
| 901 | error = ps3_irq_plug_setup(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet, | 872 | error = ps3_irq_plug_setup(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet, |
| 902 | &ps3fb.irq_no); | 873 | &ps3fb.irq_no); |
| 903 | if (error) { | 874 | if (error) { |
| @@ -907,7 +878,7 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev) | |||
| 907 | } | 878 | } |
| 908 | 879 | ||
| 909 | error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED, | 880 | error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED, |
| 910 | "ps3fb vsync", ps3fb.dev); | 881 | DEVICE_NAME, dev); |
| 911 | if (error) { | 882 | if (error) { |
| 912 | printk(KERN_ERR "%s: request_irq failed %d\n", __func__, | 883 | printk(KERN_ERR "%s: request_irq failed %d\n", __func__, |
| 913 | error); | 884 | error); |
| @@ -966,16 +937,45 @@ static struct fb_ops ps3fb_ops = { | |||
| 966 | }; | 937 | }; |
| 967 | 938 | ||
| 968 | static struct fb_fix_screeninfo ps3fb_fix __initdata = { | 939 | static struct fb_fix_screeninfo ps3fb_fix __initdata = { |
| 969 | .id = "PS3 FB", | 940 | .id = DEVICE_NAME, |
| 970 | .type = FB_TYPE_PACKED_PIXELS, | 941 | .type = FB_TYPE_PACKED_PIXELS, |
| 971 | .visual = FB_VISUAL_TRUECOLOR, | 942 | .visual = FB_VISUAL_TRUECOLOR, |
| 972 | .accel = FB_ACCEL_NONE, | 943 | .accel = FB_ACCEL_NONE, |
| 973 | }; | 944 | }; |
| 974 | 945 | ||
| 975 | static int __init ps3fb_probe(struct platform_device *dev) | 946 | static int ps3fb_set_sync(void) |
| 947 | { | ||
| 948 | int status; | ||
| 949 | |||
| 950 | #ifdef HEAD_A | ||
| 951 | status = lv1_gpu_context_attribute(0x0, | ||
| 952 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
| 953 | 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
| 954 | if (status) { | ||
| 955 | printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_SYNC " | ||
| 956 | "failed: %d\n", __func__, status); | ||
| 957 | return -1; | ||
| 958 | } | ||
| 959 | #endif | ||
| 960 | #ifdef HEAD_B | ||
| 961 | status = lv1_gpu_context_attribute(0x0, | ||
| 962 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
| 963 | 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
| 964 | |||
| 965 | if (status) { | ||
| 966 | printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_MODE " | ||
| 967 | "failed: %d\n", __func__, status); | ||
| 968 | return -1; | ||
| 969 | } | ||
| 970 | #endif | ||
| 971 | return 0; | ||
| 972 | } | ||
| 973 | |||
| 974 | static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev) | ||
| 976 | { | 975 | { |
| 977 | struct fb_info *info; | 976 | struct fb_info *info; |
| 978 | int retval = -ENOMEM; | 977 | int retval = -ENOMEM; |
| 978 | u32 xres, yres; | ||
| 979 | u64 ddr_lpar = 0; | 979 | u64 ddr_lpar = 0; |
| 980 | u64 lpar_dma_control = 0; | 980 | u64 lpar_dma_control = 0; |
| 981 | u64 lpar_driver_info = 0; | 981 | u64 lpar_driver_info = 0; |
| @@ -986,6 +986,30 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
| 986 | unsigned long offset; | 986 | unsigned long offset; |
| 987 | struct task_struct *task; | 987 | struct task_struct *task; |
| 988 | 988 | ||
| 989 | status = ps3_open_hv_device(dev); | ||
| 990 | if (status) { | ||
| 991 | printk(KERN_ERR "%s: ps3_open_hv_device failed\n", __func__); | ||
| 992 | goto err; | ||
| 993 | } | ||
| 994 | |||
| 995 | if (!ps3fb_mode) | ||
| 996 | ps3fb_mode = ps3av_get_mode(); | ||
| 997 | DPRINTK("ps3av_mode:%d\n", ps3fb_mode); | ||
| 998 | |||
| 999 | if (ps3fb_mode > 0 && | ||
| 1000 | !ps3av_video_mode2res(ps3fb_mode, &xres, &yres)) { | ||
| 1001 | ps3fb.res_index = ps3fb_get_res_table(xres, yres); | ||
| 1002 | DPRINTK("res_index:%d\n", ps3fb.res_index); | ||
| 1003 | } else | ||
| 1004 | ps3fb.res_index = GPU_RES_INDEX; | ||
| 1005 | |||
| 1006 | atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */ | ||
| 1007 | atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */ | ||
| 1008 | init_waitqueue_head(&ps3fb.wait_vsync); | ||
| 1009 | ps3fb.num_frames = 1; | ||
| 1010 | |||
| 1011 | ps3fb_set_sync(); | ||
| 1012 | |||
| 989 | /* get gpu context handle */ | 1013 | /* get gpu context handle */ |
| 990 | status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0, | 1014 | status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0, |
| 991 | &ps3fb.memory_handle, &ddr_lpar); | 1015 | &ps3fb.memory_handle, &ddr_lpar); |
| @@ -1029,7 +1053,7 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
| 1029 | * leakage into userspace | 1053 | * leakage into userspace |
| 1030 | */ | 1054 | */ |
| 1031 | memset(ps3fb.xdr_ea, 0, ps3fb_videomemory.size); | 1055 | memset(ps3fb.xdr_ea, 0, ps3fb_videomemory.size); |
| 1032 | info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev); | 1056 | info = framebuffer_alloc(sizeof(u32) * 16, &dev->core); |
| 1033 | if (!info) | 1057 | if (!info) |
| 1034 | goto err_free_irq; | 1058 | goto err_free_irq; |
| 1035 | 1059 | ||
| @@ -1061,19 +1085,20 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
| 1061 | if (retval < 0) | 1085 | if (retval < 0) |
| 1062 | goto err_fb_dealloc; | 1086 | goto err_fb_dealloc; |
| 1063 | 1087 | ||
| 1064 | platform_set_drvdata(dev, info); | 1088 | dev->core.driver_data = info; |
| 1065 | 1089 | ||
| 1066 | printk(KERN_INFO | 1090 | printk(KERN_INFO |
| 1067 | "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n", | 1091 | "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n", |
| 1068 | info->node, ps3fb_videomemory.size >> 10); | 1092 | info->node, ps3fb_videomemory.size >> 10); |
| 1069 | 1093 | ||
| 1070 | task = kthread_run(ps3fbd, info, "ps3fbd"); | 1094 | task = kthread_run(ps3fbd, info, DEVICE_NAME); |
| 1071 | if (IS_ERR(task)) { | 1095 | if (IS_ERR(task)) { |
| 1072 | retval = PTR_ERR(task); | 1096 | retval = PTR_ERR(task); |
| 1073 | goto err_unregister_framebuffer; | 1097 | goto err_unregister_framebuffer; |
| 1074 | } | 1098 | } |
| 1075 | 1099 | ||
| 1076 | ps3fb.task = task; | 1100 | ps3fb.task = task; |
| 1101 | ps3av_register_flip_ctl(ps3fb_flip_ctl, &ps3fb); | ||
| 1077 | 1102 | ||
| 1078 | return 0; | 1103 | return 0; |
| 1079 | 1104 | ||
| @@ -1084,7 +1109,7 @@ err_fb_dealloc: | |||
| 1084 | err_framebuffer_release: | 1109 | err_framebuffer_release: |
| 1085 | framebuffer_release(info); | 1110 | framebuffer_release(info); |
| 1086 | err_free_irq: | 1111 | err_free_irq: |
| 1087 | free_irq(ps3fb.irq_no, ps3fb.dev); | 1112 | free_irq(ps3fb.irq_no, dev); |
| 1088 | ps3_irq_plug_destroy(ps3fb.irq_no); | 1113 | ps3_irq_plug_destroy(ps3fb.irq_no); |
| 1089 | err_iounmap_dinfo: | 1114 | err_iounmap_dinfo: |
| 1090 | iounmap((u8 __iomem *)ps3fb.dinfo); | 1115 | iounmap((u8 __iomem *)ps3fb.dinfo); |
| @@ -1096,26 +1121,30 @@ err: | |||
| 1096 | return retval; | 1121 | return retval; |
| 1097 | } | 1122 | } |
| 1098 | 1123 | ||
| 1099 | static void ps3fb_shutdown(struct platform_device *dev) | 1124 | static int ps3fb_shutdown(struct ps3_system_bus_device *dev) |
| 1100 | { | 1125 | { |
| 1101 | ps3fb_flip_ctl(0); /* flip off */ | 1126 | int status; |
| 1127 | struct fb_info *info = dev->core.driver_data; | ||
| 1128 | |||
| 1129 | DPRINTK(" -> %s:%d\n", __func__, __LINE__); | ||
| 1130 | |||
| 1131 | ps3fb_flip_ctl(0, &ps3fb); /* flip off */ | ||
| 1102 | ps3fb.dinfo->irq.mask = 0; | 1132 | ps3fb.dinfo->irq.mask = 0; |
| 1103 | free_irq(ps3fb.irq_no, ps3fb.dev); | ||
| 1104 | ps3_irq_plug_destroy(ps3fb.irq_no); | ||
| 1105 | iounmap((u8 __iomem *)ps3fb.dinfo); | ||
| 1106 | } | ||
| 1107 | 1133 | ||
| 1108 | void ps3fb_cleanup(void) | 1134 | if (info) { |
| 1109 | { | 1135 | unregister_framebuffer(info); |
| 1110 | int status; | 1136 | fb_dealloc_cmap(&info->cmap); |
| 1137 | framebuffer_release(info); | ||
| 1138 | } | ||
| 1111 | 1139 | ||
| 1140 | ps3av_register_flip_ctl(NULL, NULL); | ||
| 1112 | if (ps3fb.task) { | 1141 | if (ps3fb.task) { |
| 1113 | struct task_struct *task = ps3fb.task; | 1142 | struct task_struct *task = ps3fb.task; |
| 1114 | ps3fb.task = NULL; | 1143 | ps3fb.task = NULL; |
| 1115 | kthread_stop(task); | 1144 | kthread_stop(task); |
| 1116 | } | 1145 | } |
| 1117 | if (ps3fb.irq_no) { | 1146 | if (ps3fb.irq_no) { |
| 1118 | free_irq(ps3fb.irq_no, ps3fb.dev); | 1147 | free_irq(ps3fb.irq_no, dev); |
| 1119 | ps3_irq_plug_destroy(ps3fb.irq_no); | 1148 | ps3_irq_plug_destroy(ps3fb.irq_no); |
| 1120 | } | 1149 | } |
| 1121 | iounmap((u8 __iomem *)ps3fb.dinfo); | 1150 | iounmap((u8 __iomem *)ps3fb.dinfo); |
| @@ -1128,134 +1157,69 @@ void ps3fb_cleanup(void) | |||
| 1128 | if (status) | 1157 | if (status) |
| 1129 | DPRINTK("lv1_gpu_memory_free failed: %d\n", status); | 1158 | DPRINTK("lv1_gpu_memory_free failed: %d\n", status); |
| 1130 | 1159 | ||
| 1131 | ps3av_dev_close(); | 1160 | ps3_close_hv_device(dev); |
| 1132 | } | 1161 | DPRINTK(" <- %s:%d\n", __func__, __LINE__); |
| 1133 | 1162 | ||
| 1134 | EXPORT_SYMBOL_GPL(ps3fb_cleanup); | ||
| 1135 | |||
| 1136 | static int ps3fb_remove(struct platform_device *dev) | ||
| 1137 | { | ||
| 1138 | struct fb_info *info = platform_get_drvdata(dev); | ||
| 1139 | |||
| 1140 | if (info) { | ||
| 1141 | unregister_framebuffer(info); | ||
| 1142 | fb_dealloc_cmap(&info->cmap); | ||
| 1143 | framebuffer_release(info); | ||
| 1144 | } | ||
| 1145 | ps3fb_cleanup(); | ||
| 1146 | return 0; | 1163 | return 0; |
| 1147 | } | 1164 | } |
| 1148 | 1165 | ||
| 1149 | static struct platform_driver ps3fb_driver = { | 1166 | static struct ps3_system_bus_driver ps3fb_driver = { |
| 1150 | .probe = ps3fb_probe, | 1167 | .match_id = PS3_MATCH_ID_GRAPHICS, |
| 1151 | .remove = ps3fb_remove, | 1168 | .core.name = DEVICE_NAME, |
| 1152 | .shutdown = ps3fb_shutdown, | 1169 | .core.owner = THIS_MODULE, |
| 1153 | .driver = { .name = "ps3fb" } | 1170 | .probe = ps3fb_probe, |
| 1154 | }; | 1171 | .remove = ps3fb_shutdown, |
| 1155 | 1172 | .shutdown = ps3fb_shutdown, | |
| 1156 | static struct platform_device ps3fb_device = { | ||
| 1157 | .name = "ps3fb", | ||
| 1158 | .id = 0, | ||
| 1159 | .dev = { .release = ps3fb_platform_release } | ||
| 1160 | }; | 1173 | }; |
| 1161 | 1174 | ||
| 1162 | int ps3fb_set_sync(void) | 1175 | static int __init ps3fb_setup(void) |
| 1163 | { | 1176 | { |
| 1164 | int status; | 1177 | char *options; |
| 1165 | 1178 | ||
| 1166 | #ifdef HEAD_A | 1179 | #ifdef MODULE |
| 1167 | status = lv1_gpu_context_attribute(0x0, | ||
| 1168 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
| 1169 | 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
| 1170 | if (status) { | ||
| 1171 | printk(KERN_ERR | ||
| 1172 | "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: %d\n", | ||
| 1173 | __func__, status); | ||
| 1174 | return -1; | ||
| 1175 | } | ||
| 1176 | #endif | ||
| 1177 | #ifdef HEAD_B | ||
| 1178 | status = lv1_gpu_context_attribute(0x0, | ||
| 1179 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | ||
| 1180 | 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | ||
| 1181 | |||
| 1182 | if (status) { | ||
| 1183 | printk(KERN_ERR | ||
| 1184 | "%s: lv1_gpu_context_attribute DISPLAY_MODE failed: %d\n", | ||
| 1185 | __func__, status); | ||
| 1186 | return -1; | ||
| 1187 | } | ||
| 1188 | #endif | ||
| 1189 | return 0; | 1180 | return 0; |
| 1190 | } | ||
| 1191 | |||
| 1192 | EXPORT_SYMBOL_GPL(ps3fb_set_sync); | ||
| 1193 | |||
| 1194 | static int __init ps3fb_init(void) | ||
| 1195 | { | ||
| 1196 | int error; | ||
| 1197 | #ifndef MODULE | ||
| 1198 | int mode; | ||
| 1199 | char *option = NULL; | ||
| 1200 | |||
| 1201 | if (fb_get_options("ps3fb", &option)) | ||
| 1202 | goto err; | ||
| 1203 | #endif | 1181 | #endif |
| 1204 | 1182 | ||
| 1205 | if (!ps3fb_videomemory.address) | 1183 | if (fb_get_options(DEVICE_NAME, &options)) |
| 1206 | goto err; | 1184 | return -ENXIO; |
| 1207 | |||
| 1208 | error = ps3av_dev_open(); | ||
| 1209 | if (error) { | ||
| 1210 | printk(KERN_ERR "%s: ps3av_dev_open failed\n", __func__); | ||
| 1211 | goto err; | ||
| 1212 | } | ||
| 1213 | 1185 | ||
| 1214 | ps3fb_mode = ps3av_get_mode(); | 1186 | if (!options || !*options) |
| 1215 | DPRINTK("ps3av_mode:%d\n", ps3fb_mode); | 1187 | return 0; |
| 1216 | #ifndef MODULE | ||
| 1217 | mode = ps3fb_setup(option); /* check boot option */ | ||
| 1218 | if (mode) | ||
| 1219 | ps3fb_mode = mode; | ||
| 1220 | #endif | ||
| 1221 | if (ps3fb_mode > 0) { | ||
| 1222 | u32 xres, yres; | ||
| 1223 | ps3av_video_mode2res(ps3fb_mode, &xres, &yres); | ||
| 1224 | ps3fb.res_index = ps3fb_get_res_table(xres, yres); | ||
| 1225 | DPRINTK("res_index:%d\n", ps3fb.res_index); | ||
| 1226 | } else | ||
| 1227 | ps3fb.res_index = GPU_RES_INDEX; | ||
| 1228 | 1188 | ||
| 1229 | atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */ | 1189 | while (1) { |
| 1230 | atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */ | 1190 | char *this_opt = strsep(&options, ","); |
| 1231 | init_waitqueue_head(&ps3fb.wait_vsync); | ||
| 1232 | ps3fb.num_frames = 1; | ||
| 1233 | 1191 | ||
| 1234 | error = platform_driver_register(&ps3fb_driver); | 1192 | if (!this_opt) |
| 1235 | if (!error) { | 1193 | break; |
| 1236 | error = platform_device_register(&ps3fb_device); | 1194 | if (!*this_opt) |
| 1237 | if (error) | 1195 | continue; |
| 1238 | platform_driver_unregister(&ps3fb_driver); | 1196 | if (!strncmp(this_opt, "mode:", 5)) |
| 1197 | ps3fb_mode = simple_strtoul(this_opt + 5, NULL, 0); | ||
| 1198 | else | ||
| 1199 | mode_option = this_opt; | ||
| 1239 | } | 1200 | } |
| 1201 | return 0; | ||
| 1202 | } | ||
| 1240 | 1203 | ||
| 1241 | ps3fb_set_sync(); | 1204 | static int __init ps3fb_init(void) |
| 1242 | 1205 | { | |
| 1243 | return error; | 1206 | if (!ps3fb_videomemory.address || ps3fb_setup()) |
| 1207 | return -ENXIO; | ||
| 1244 | 1208 | ||
| 1245 | err: | 1209 | return ps3_system_bus_driver_register(&ps3fb_driver); |
| 1246 | return -ENXIO; | ||
| 1247 | } | 1210 | } |
| 1248 | 1211 | ||
| 1249 | module_init(ps3fb_init); | ||
| 1250 | |||
| 1251 | #ifdef MODULE | ||
| 1252 | static void __exit ps3fb_exit(void) | 1212 | static void __exit ps3fb_exit(void) |
| 1253 | { | 1213 | { |
| 1254 | platform_device_unregister(&ps3fb_device); | 1214 | DPRINTK(" -> %s:%d\n", __func__, __LINE__); |
| 1255 | platform_driver_unregister(&ps3fb_driver); | 1215 | ps3_system_bus_driver_unregister(&ps3fb_driver); |
| 1216 | DPRINTK(" <- %s:%d\n", __func__, __LINE__); | ||
| 1256 | } | 1217 | } |
| 1257 | 1218 | ||
| 1219 | module_init(ps3fb_init); | ||
| 1258 | module_exit(ps3fb_exit); | 1220 | module_exit(ps3fb_exit); |
| 1259 | 1221 | ||
| 1260 | MODULE_LICENSE("GPL"); | 1222 | MODULE_LICENSE("GPL"); |
| 1261 | #endif /* MODULE */ | 1223 | MODULE_DESCRIPTION("PS3 GPU Frame Buffer Driver"); |
| 1224 | MODULE_AUTHOR("Sony Computer Entertainment Inc."); | ||
| 1225 | MODULE_ALIAS(PS3_MODULE_ALIAS_GRAPHICS); | ||
