ps3_syscons.c (230992) | ps3_syscons.c (265871) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2003 Peter Grehan | 2 * Copyright (c) 2011-2014 Nathan Whitehorn |
3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 9 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 9 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/powerpc/ps3/ps3_syscons.c 230992 2012-02-04 19:50:26Z nwhitehorn $"); | 28__FBSDID("$FreeBSD: head/sys/powerpc/ps3/ps3_syscons.c 265871 2014-05-11 05:49:35Z nwhitehorn $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> | 29 30#include <sys/param.h> 31#include <sys/systm.h> |
32#include <sys/module.h> 33#include <sys/bus.h> | |
34#include <sys/kernel.h> 35#include <sys/sysctl.h> 36#include <sys/limits.h> 37#include <sys/conf.h> 38#include <sys/cons.h> | 32#include <sys/kernel.h> 33#include <sys/sysctl.h> 34#include <sys/limits.h> 35#include <sys/conf.h> 36#include <sys/cons.h> |
39#include <sys/proc.h> 40#include <sys/fcntl.h> 41#include <sys/malloc.h> | |
42#include <sys/fbio.h> | 37#include <sys/fbio.h> |
43#include <sys/consio.h> | |
44 45#include <vm/vm.h> 46#include <vm/pmap.h> 47 | 38 39#include <vm/vm.h> 40#include <vm/pmap.h> 41 |
48#include <machine/bus.h> 49#include <machine/sc_machdep.h> | |
50#include <machine/platform.h> 51#include <machine/pmap.h> 52 | 42#include <machine/platform.h> 43#include <machine/pmap.h> 44 |
53#include <sys/rman.h> | 45#include <dev/vt/vt.h> 46#include <dev/vt/hw/fb/vt_fb.h> 47#include <dev/vt/colors/vt_termcolors.h> |
54 | 48 |
55#include <dev/fb/fbreg.h> 56#include <dev/syscons/syscons.h> 57 | |
58#include "ps3-hvcall.h" 59 60#define PS3FB_SIZE (4*1024*1024) 61 62#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET 0x0100 63#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC 0x0101 64#define L1GPU_DISPLAY_SYNC_HSYNC 1 65#define L1GPU_DISPLAY_SYNC_VSYNC 2 66#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP 0x0102 67 | 49#include "ps3-hvcall.h" 50 51#define PS3FB_SIZE (4*1024*1024) 52 53#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET 0x0100 54#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC 0x0101 55#define L1GPU_DISPLAY_SYNC_HSYNC 1 56#define L1GPU_DISPLAY_SYNC_VSYNC 2 57#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP 0x0102 58 |
68extern u_char dflt_font_16[]; 69extern u_char dflt_font_14[]; 70extern u_char dflt_font_8[]; 71 72static int ps3fb_configure(int flags); | 59static vd_init_t ps3fb_init; 60static vd_probe_t ps3fb_probe; |
73void ps3fb_remap(void); 74 | 61void ps3fb_remap(void); 62 |
75static vi_probe_t ps3fb_probe; 76static vi_init_t ps3fb_init; 77static vi_get_info_t ps3fb_get_info; 78static vi_query_mode_t ps3fb_query_mode; 79static vi_set_mode_t ps3fb_set_mode; 80static vi_save_font_t ps3fb_save_font; 81static vi_load_font_t ps3fb_load_font; 82static vi_show_font_t ps3fb_show_font; 83static vi_save_palette_t ps3fb_save_palette; 84static vi_load_palette_t ps3fb_load_palette; 85static vi_set_border_t ps3fb_set_border; 86static vi_save_state_t ps3fb_save_state; 87static vi_load_state_t ps3fb_load_state; 88static vi_set_win_org_t ps3fb_set_win_org; 89static vi_read_hw_cursor_t ps3fb_read_hw_cursor; 90static vi_set_hw_cursor_t ps3fb_set_hw_cursor; 91static vi_set_hw_cursor_shape_t ps3fb_set_hw_cursor_shape; 92static vi_blank_display_t ps3fb_blank_display; 93static vi_mmap_t ps3fb_mmap; 94static vi_ioctl_t ps3fb_ioctl; 95static vi_clear_t ps3fb_clear; 96static vi_fill_rect_t ps3fb_fill_rect; 97static vi_bitblt_t ps3fb_bitblt; 98static vi_diag_t ps3fb_diag; 99static vi_save_cursor_palette_t ps3fb_save_cursor_palette; 100static vi_load_cursor_palette_t ps3fb_load_cursor_palette; 101static vi_copy_t ps3fb_copy; 102static vi_putp_t ps3fb_putp; 103static vi_putc_t ps3fb_putc; 104static vi_puts_t ps3fb_puts; 105static vi_putm_t ps3fb_putm; 106 | |
107struct ps3fb_softc { | 63struct ps3fb_softc { |
108 video_adapter_t sc_va; 109 struct cdev *sc_si; 110 int sc_console; | 64 struct fb_info fb_info; |
111 | 65 |
112 intptr_t sc_addr; 113 int sc_height; 114 int sc_width; 115 int sc_stride; 116 int sc_ncol; 117 int sc_nrow; 118 119 int sc_xmargin; 120 int sc_ymargin; 121 122 u_char *sc_font; 123 int sc_font_height; 124 | |
125 uint64_t sc_fbhandle; 126 uint64_t sc_fbcontext; 127 uint64_t sc_dma_control; 128 uint64_t sc_driver_info; 129 uint64_t sc_reports; 130 uint64_t sc_reports_size; 131}; 132 | 66 uint64_t sc_fbhandle; 67 uint64_t sc_fbcontext; 68 uint64_t sc_dma_control; 69 uint64_t sc_driver_info; 70 uint64_t sc_reports; 71 uint64_t sc_reports_size; 72}; 73 |
133static video_switch_t ps3fbvidsw = { 134 .probe = ps3fb_probe, 135 .init = ps3fb_init, 136 .get_info = ps3fb_get_info, 137 .query_mode = ps3fb_query_mode, 138 .set_mode = ps3fb_set_mode, 139 .save_font = ps3fb_save_font, 140 .load_font = ps3fb_load_font, 141 .show_font = ps3fb_show_font, 142 .save_palette = ps3fb_save_palette, 143 .load_palette = ps3fb_load_palette, 144 .set_border = ps3fb_set_border, 145 .save_state = ps3fb_save_state, 146 .load_state = ps3fb_load_state, 147 .set_win_org = ps3fb_set_win_org, 148 .read_hw_cursor = ps3fb_read_hw_cursor, 149 .set_hw_cursor = ps3fb_set_hw_cursor, 150 .set_hw_cursor_shape = ps3fb_set_hw_cursor_shape, 151 .blank_display = ps3fb_blank_display, 152 .mmap = ps3fb_mmap, 153 .ioctl = ps3fb_ioctl, 154 .clear = ps3fb_clear, 155 .fill_rect = ps3fb_fill_rect, 156 .bitblt = ps3fb_bitblt, 157 .diag = ps3fb_diag, 158 .save_cursor_palette = ps3fb_save_cursor_palette, 159 .load_cursor_palette = ps3fb_load_cursor_palette, 160 .copy = ps3fb_copy, 161 .putp = ps3fb_putp, 162 .putc = ps3fb_putc, 163 .puts = ps3fb_puts, 164 .putm = ps3fb_putm, | 74static struct vt_driver vt_ps3fb_driver = { 75 .vd_name = "ps3fb", 76 .vd_probe = ps3fb_probe, 77 .vd_init = ps3fb_init, 78 .vd_blank = vt_fb_blank, 79 .vd_bitbltchr = vt_fb_bitbltchr, 80 .vd_maskbitbltchr = vt_fb_maskbitbltchr, 81 /* Better than VGA, but still generic driver. */ 82 .vd_priority = VD_PRIORITY_GENERIC + 1, |
165}; 166 | 83}; 84 |
167VIDEO_DRIVER(ps3fb, ps3fbvidsw, ps3fb_configure); 168 169extern sc_rndr_sw_t txtrndrsw; 170RENDERER(ps3fb, 0, txtrndrsw, gfb_set); 171 172RENDERER_MODULE(ps3fb, gfb_set); 173 174/* 175 * Define the iso6429-1983 colormap 176 */ 177static struct { 178 uint8_t red; 179 uint8_t green; 180 uint8_t blue; 181} ps3fb_cmap[16] = { /* # R G B Color */ 182 /* - - - - ----- */ 183 { 0x00, 0x00, 0x00 }, /* 0 0 0 0 Black */ 184 { 0x00, 0x00, 0xaa }, /* 1 0 0 2/3 Blue */ 185 { 0x00, 0xaa, 0x00 }, /* 2 0 2/3 0 Green */ 186 { 0x00, 0xaa, 0xaa }, /* 3 0 2/3 2/3 Cyan */ 187 { 0xaa, 0x00, 0x00 }, /* 4 2/3 0 0 Red */ 188 { 0xaa, 0x00, 0xaa }, /* 5 2/3 0 2/3 Magenta */ 189 { 0xaa, 0x55, 0x00 }, /* 6 2/3 1/3 0 Brown */ 190 { 0xaa, 0xaa, 0xaa }, /* 7 2/3 2/3 2/3 White */ 191 { 0x55, 0x55, 0x55 }, /* 8 1/3 1/3 1/3 Gray */ 192 { 0x55, 0x55, 0xff }, /* 9 1/3 1/3 1 Bright Blue */ 193 { 0x55, 0xff, 0x55 }, /* 10 1/3 1 1/3 Bright Green */ 194 { 0x55, 0xff, 0xff }, /* 11 1/3 1 1 Bright Cyan */ 195 { 0xff, 0x55, 0x55 }, /* 12 1 1/3 1/3 Bright Red */ 196 { 0xff, 0x55, 0xff }, /* 13 1 1/3 1 Bright Magenta */ 197 { 0xff, 0xff, 0x80 }, /* 14 1 1 1/3 Bright Yellow */ 198 { 0xff, 0xff, 0xff } /* 15 1 1 1 Bright White */ 199}; 200 201#define TODO printf("%s: unimplemented\n", __func__) 202 203static u_int16_t ps3fb_static_window[ROW*COL]; 204 | 85VT_DRIVER_DECLARE(vt_ps3fb, vt_ps3fb_driver); |
205static struct ps3fb_softc ps3fb_softc; 206 | 86static struct ps3fb_softc ps3fb_softc; 87 |
207static __inline int 208ps3fb_background(uint8_t attr) 209{ 210 return (attr >> 4); 211} 212 213static __inline int 214ps3fb_foreground(uint8_t attr) 215{ 216 return (attr & 0x0f); 217} 218 219static u_int 220ps3fb_pix32(int attr) 221{ 222 u_int retval; 223 224 retval = (ps3fb_cmap[attr].red << 16) | 225 (ps3fb_cmap[attr].green << 8) | 226 ps3fb_cmap[attr].blue; 227 228 return (retval); 229} 230 | |
231static int | 88static int |
232ps3fb_configure(int flags) | 89ps3fb_probe(struct vt_device *vd) |
233{ 234 struct ps3fb_softc *sc; 235 int disable; 236 char compatible[64]; 237#if 0 238 phandle_t root; 239#endif | 90{ 91 struct ps3fb_softc *sc; 92 int disable; 93 char compatible[64]; 94#if 0 95 phandle_t root; 96#endif |
240 static int done = 0; | |
241 242 disable = 0; 243 TUNABLE_INT_FETCH("hw.syscons.disable", &disable); 244 if (disable != 0) 245 return (0); 246 | 97 98 disable = 0; 99 TUNABLE_INT_FETCH("hw.syscons.disable", &disable); 100 if (disable != 0) 101 return (0); 102 |
247 if (done != 0) 248 return (0); 249 done = 1; 250 | |
251 sc = &ps3fb_softc; 252 253#if 0 254 root = OF_finddevice("/"); 255 if (OF_getprop(root, "compatible", compatible, sizeof(compatible)) <= 0) 256 return (0); 257 258 if (strncmp(compatible, "sony,ps3", sizeof(compatible)) != 0) 259 return (0); 260#else 261 TUNABLE_STR_FETCH("hw.platform", compatible, sizeof(compatible)); 262 if (strcmp(compatible, "ps3") != 0) | 103 sc = &ps3fb_softc; 104 105#if 0 106 root = OF_finddevice("/"); 107 if (OF_getprop(root, "compatible", compatible, sizeof(compatible)) <= 0) 108 return (0); 109 110 if (strncmp(compatible, "sony,ps3", sizeof(compatible)) != 0) 111 return (0); 112#else 113 TUNABLE_STR_FETCH("hw.platform", compatible, sizeof(compatible)); 114 if (strcmp(compatible, "ps3") != 0) |
263 return (0); | 115 return (CN_DEAD); |
264#endif 265 | 116#endif 117 |
266 sc->sc_console = 1; 267 268 /* XXX: get from HV repository */ 269 sc->sc_height = 480; 270 sc->sc_width = 720; 271 sc->sc_stride = sc->sc_width*4; 272 273 /* 274 * The loader puts the FB at 0x10000000, so use that for now. 275 */ 276 277 sc->sc_addr = 0x10000000; 278 ps3fb_init(0, &sc->sc_va, 0); 279 280 return (0); | 118 return (CN_INTERNAL); |
281} 282 283void 284ps3fb_remap(void) 285{ 286 struct ps3fb_softc *sc; 287 vm_offset_t va, fb_paddr; 288 --- 5 unchanged lines hidden (view full) --- 294 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET, 295 0,0,0,0); 296 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET, 297 0,0,1,0); 298 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, 299 0,L1GPU_DISPLAY_SYNC_VSYNC,0,0); 300 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, 301 1,L1GPU_DISPLAY_SYNC_VSYNC,0,0); | 119} 120 121void 122ps3fb_remap(void) 123{ 124 struct ps3fb_softc *sc; 125 vm_offset_t va, fb_paddr; 126 --- 5 unchanged lines hidden (view full) --- 132 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET, 133 0,0,0,0); 134 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET, 135 0,0,1,0); 136 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, 137 0,L1GPU_DISPLAY_SYNC_VSYNC,0,0); 138 lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, 139 1,L1GPU_DISPLAY_SYNC_VSYNC,0,0); |
302 lv1_gpu_memory_allocate(PS3FB_SIZE, 0, 0, 0, 0, &sc->sc_fbhandle, &fb_paddr); 303 lv1_gpu_context_allocate(sc->sc_fbhandle, 0, &sc->sc_fbcontext, &sc->sc_dma_control, 304 &sc->sc_driver_info, &sc->sc_reports, &sc->sc_reports_size); | 140 lv1_gpu_memory_allocate(PS3FB_SIZE, 0, 0, 0, 0, &sc->sc_fbhandle, 141 &fb_paddr); 142 lv1_gpu_context_allocate(sc->sc_fbhandle, 0, &sc->sc_fbcontext, 143 &sc->sc_dma_control, &sc->sc_driver_info, &sc->sc_reports, 144 &sc->sc_reports_size); |
305 306 lv1_gpu_context_attribute(sc->sc_fbcontext, 307 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 0, 0, 0, 0); 308 lv1_gpu_context_attribute(sc->sc_fbcontext, 309 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0); 310 | 145 146 lv1_gpu_context_attribute(sc->sc_fbcontext, 147 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 0, 0, 0, 0); 148 lv1_gpu_context_attribute(sc->sc_fbcontext, 149 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0); 150 |
151 sc->fb_info.fb_pbase = fb_paddr; |
|
311 for (va = 0; va < PS3FB_SIZE; va += PAGE_SIZE) 312 pmap_kenter_attr(0x10000000 + va, fb_paddr + va, 313 VM_MEMATTR_WRITE_COMBINING); 314} 315 316static int | 152 for (va = 0; va < PS3FB_SIZE; va += PAGE_SIZE) 153 pmap_kenter_attr(0x10000000 + va, fb_paddr + va, 154 VM_MEMATTR_WRITE_COMBINING); 155} 156 157static int |
317ps3fb_probe(int unit, video_adapter_t **adp, void *arg, int flags) | 158ps3fb_init(struct vt_device *vd) |
318{ | 159{ |
319 TODO; 320 return (0); 321} 322 323static int 324ps3fb_init(int unit, video_adapter_t *adp, int flags) 325{ | |
326 struct ps3fb_softc *sc; | 160 struct ps3fb_softc *sc; |
327 video_info_t *vi; 328 int cxborder, cyborder; 329 int font_height; | |
330 | 161 |
331 sc = (struct ps3fb_softc *)adp; 332 vi = &adp->va_info; | 162 /* Init softc */ 163 vd->vd_softc = sc = &ps3fb_softc; |
333 | 164 |
334 vid_init_struct(adp, "ps3fb", -1, unit); | 165 /* XXX: get from HV repository */ 166 sc->fb_info.fb_depth = 32; 167 sc->fb_info.fb_height = 480; 168 sc->fb_info.fb_width = 720; 169 sc->fb_info.fb_stride = sc->fb_info.fb_width*4; 170 sc->fb_info.fb_size = sc->fb_info.fb_height * sc->fb_info.fb_stride; 171 sc->fb_info.fb_bpp = sc->fb_info.fb_stride / sc->fb_info.fb_width * 8; |
335 | 172 |
336 /* The default font size can be overridden by loader */ 337 font_height = 16; 338 TUNABLE_INT_FETCH("hw.syscons.fsize", &font_height); 339 if (font_height == 8) { 340 sc->sc_font = dflt_font_8; 341 sc->sc_font_height = 8; 342 } else if (font_height == 14) { 343 sc->sc_font = dflt_font_14; 344 sc->sc_font_height = 14; 345 } else { 346 /* default is 8x16 */ 347 sc->sc_font = dflt_font_16; 348 sc->sc_font_height = 16; 349 } 350 351 /* The user can set a border in chars - default is 1 char width */ 352 cxborder = 8; 353 cyborder = 2; 354 TUNABLE_INT_FETCH("hw.syscons.xborder", &cxborder); 355 TUNABLE_INT_FETCH("hw.syscons.yborder", &cyborder); 356 357 vi->vi_cheight = sc->sc_font_height; 358 vi->vi_width = sc->sc_width/8 - 2*cxborder; 359 vi->vi_height = sc->sc_height/sc->sc_font_height - 2*cyborder; 360 vi->vi_cwidth = 8; 361 | |
362 /* | 173 /* |
363 * Clamp width/height to syscons maximums | 174 * The loader puts the FB at 0x10000000, so use that for now. |
364 */ | 175 */ |
365 if (vi->vi_width > COL) 366 vi->vi_width = COL; 367 if (vi->vi_height > ROW) 368 vi->vi_height = ROW; | |
369 | 176 |
370 sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2; 371 sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight))/2; | 177 sc->fb_info.fb_vbase = 0x10000000; |
372 | 178 |
373 /* 374 * Avoid huge amounts of conditional code in syscons by 375 * defining a dummy h/w text display buffer. 376 */ 377 adp->va_window = (vm_offset_t) ps3fb_static_window; | 179 /* 32-bit VGA palette */ 180 vt_generate_vga_palette(sc->fb_info.fb_cmap, COLOR_FORMAT_RGB, 181 255, 16, 255, 8, 255, 0); |
378 | 182 |
379 /* 380 * Enable future font-loading and flag color support, as well as 381 * adding V_ADP_MODECHANGE so that we ps3fb_set_mode() gets called 382 * when the X server shuts down. This enables us to get the console 383 * back when X disappears. 384 */ 385 adp->va_flags |= V_ADP_FONT | V_ADP_COLOR | V_ADP_MODECHANGE; 386 387 ps3fb_set_mode(&sc->sc_va, 0); 388 vid_register(&sc->sc_va); 389 390 return (0); 391} 392 393static int 394ps3fb_get_info(video_adapter_t *adp, int mode, video_info_t *info) 395{ 396 bcopy(&adp->va_info, info, sizeof(*info)); 397 return (0); 398} 399 400static int 401ps3fb_query_mode(video_adapter_t *adp, video_info_t *info) 402{ 403 TODO; 404 return (0); 405} 406 407static int 408ps3fb_set_mode(video_adapter_t *adp, int mode) 409{ 410 struct ps3fb_softc *sc; 411 412 sc = (struct ps3fb_softc *)adp; 413 414 /* XXX: no real mode setting at the moment */ 415 416 ps3fb_blank_display(&sc->sc_va, V_DISPLAY_ON); 417 | 183 /* Set correct graphics context */ |
418 lv1_gpu_context_attribute(sc->sc_fbcontext, 419 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 0, 0, 0, 0); 420 lv1_gpu_context_attribute(sc->sc_fbcontext, 421 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0); 422 | 184 lv1_gpu_context_attribute(sc->sc_fbcontext, 185 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 0, 0, 0, 0); 186 lv1_gpu_context_attribute(sc->sc_fbcontext, 187 L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0); 188 |
423 return (0); 424} | 189 fb_probe(&sc->fb_info); 190 vt_fb_init(vd); |
425 | 191 |
426static int 427ps3fb_save_font(video_adapter_t *adp, int page, int size, int width, 428 u_char *data, int c, int count) 429{ 430 TODO; 431 return (0); 432} | 192 /* Clear the screen. */ 193 vt_fb_blank(vd, TC_BLACK); |
433 | 194 |
434static int 435ps3fb_load_font(video_adapter_t *adp, int page, int size, int width, 436 u_char *data, int c, int count) 437{ 438 struct ps3fb_softc *sc; 439 440 sc = (struct ps3fb_softc *)adp; 441 442 /* 443 * syscons code has already determined that current width/height 444 * are unchanged for this new font 445 */ 446 sc->sc_font = data; 447 return (0); | 195 return (CN_INTERNAL); |
448} 449 | 196} 197 |
450static int 451ps3fb_show_font(video_adapter_t *adp, int page) 452{ 453 454 return (0); 455} 456 457static int 458ps3fb_save_palette(video_adapter_t *adp, u_char *palette) 459{ 460 /* TODO; */ 461 return (0); 462} 463 464static int 465ps3fb_load_palette(video_adapter_t *adp, u_char *palette) 466{ 467 /* TODO; */ 468 return (0); 469} 470 471static int 472ps3fb_set_border(video_adapter_t *adp, int border) 473{ 474 /* XXX Be lazy for now and blank entire screen */ 475 return (ps3fb_blank_display(adp, border)); 476} 477 478static int 479ps3fb_save_state(video_adapter_t *adp, void *p, size_t size) 480{ 481 TODO; 482 return (0); 483} 484 485static int 486ps3fb_load_state(video_adapter_t *adp, void *p) 487{ 488 TODO; 489 return (0); 490} 491 492static int 493ps3fb_set_win_org(video_adapter_t *adp, off_t offset) 494{ 495 TODO; 496 return (0); 497} 498 499static int 500ps3fb_read_hw_cursor(video_adapter_t *adp, int *col, int *row) 501{ 502 *col = 0; 503 *row = 0; 504 505 return (0); 506} 507 508static int 509ps3fb_set_hw_cursor(video_adapter_t *adp, int col, int row) 510{ 511 512 return (0); 513} 514 515static int 516ps3fb_set_hw_cursor_shape(video_adapter_t *adp, int base, int height, 517 int celsize, int blink) 518{ 519 return (0); 520} 521 522static int 523ps3fb_blank_display(video_adapter_t *adp, int mode) 524{ 525 struct ps3fb_softc *sc; 526 int i; 527 uint32_t *addr; 528 529 sc = (struct ps3fb_softc *)adp; 530 addr = (uint32_t *) sc->sc_addr; 531 532 for (i = 0; i < (sc->sc_stride/4)*sc->sc_height; i++) 533 *(addr + i) = ps3fb_pix32(ps3fb_background(SC_NORM_ATTR)); 534 535 return (0); 536} 537 538static int 539ps3fb_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr, 540 int prot, vm_memattr_t *memattr) 541{ 542 struct ps3fb_softc *sc; 543 544 sc = (struct ps3fb_softc *)adp; 545 546 /* 547 * This might be a legacy VGA mem request: if so, just point it at the 548 * framebuffer, since it shouldn't be touched 549 */ 550 if (offset < sc->sc_stride*sc->sc_height) { 551 *paddr = sc->sc_addr + offset; 552 return (0); 553 } 554 555 return (EINVAL); 556} 557 558static int 559ps3fb_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data) 560{ 561 562 return (0); 563} 564 565static int 566ps3fb_clear(video_adapter_t *adp) 567{ 568 TODO; 569 return (0); 570} 571 572static int 573ps3fb_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy) 574{ 575 TODO; 576 return (0); 577} 578 579static int 580ps3fb_bitblt(video_adapter_t *adp, ...) 581{ 582 TODO; 583 return (0); 584} 585 586static int 587ps3fb_diag(video_adapter_t *adp, int level) 588{ 589 TODO; 590 return (0); 591} 592 593static int 594ps3fb_save_cursor_palette(video_adapter_t *adp, u_char *palette) 595{ 596 TODO; 597 return (0); 598} 599 600static int 601ps3fb_load_cursor_palette(video_adapter_t *adp, u_char *palette) 602{ 603 TODO; 604 return (0); 605} 606 607static int 608ps3fb_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n) 609{ 610 TODO; 611 return (0); 612} 613 614static int 615ps3fb_putp(video_adapter_t *adp, vm_offset_t off, uint32_t p, uint32_t a, 616 int size, int bpp, int bit_ltor, int byte_ltor) 617{ 618 TODO; 619 return (0); 620} 621 622static int 623ps3fb_putc(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a) 624{ 625 struct ps3fb_softc *sc; 626 int row; 627 int col; 628 int i, j, k; 629 uint32_t *addr; 630 u_char *p; 631 632 sc = (struct ps3fb_softc *)adp; 633 row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight; 634 col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth; 635 p = sc->sc_font + c*sc->sc_font_height; 636 addr = (uint32_t *)sc->sc_addr 637 + (row + sc->sc_ymargin)*(sc->sc_stride/4) 638 + col + sc->sc_xmargin; 639 640 for (i = 0; i < sc->sc_font_height; i++) { 641 for (j = 0, k = 7; j < 8; j++, k--) { 642 if ((p[i] & (1 << k)) == 0) 643 *(addr + j) = ps3fb_pix32(ps3fb_background(a)); 644 else 645 *(addr + j) = ps3fb_pix32(ps3fb_foreground(a)); 646 } 647 addr += (sc->sc_stride/4); 648 } 649 650 return (0); 651} 652 653static int 654ps3fb_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len) 655{ 656 int i; 657 658 for (i = 0; i < len; i++) { 659 ps3fb_putc(adp, off + i, s[i] & 0xff, (s[i] & 0xff00) >> 8); 660 } 661 return (0); 662} 663 664static int 665ps3fb_putm(video_adapter_t *adp, int x, int y, uint8_t *pixel_image, 666 uint32_t pixel_mask, int size, int width) 667{ 668 struct ps3fb_softc *sc; 669 int i, j, k; 670 uint32_t fg, bg; 671 uint32_t *addr; 672 673 sc = (struct ps3fb_softc *)adp; 674 addr = (uint32_t *)sc->sc_addr 675 + (y + sc->sc_ymargin)*(sc->sc_stride/4) 676 + x + sc->sc_xmargin; 677 678 fg = ps3fb_pix32(ps3fb_foreground(SC_NORM_ATTR)); 679 bg = ps3fb_pix32(ps3fb_background(SC_NORM_ATTR)); 680 681 for (i = 0; i < size && i+y < sc->sc_height - 2*sc->sc_ymargin; i++) { 682 for (j = 0, k = width; j < 8; j++, k--) { 683 if (x + j >= sc->sc_width - 2*sc->sc_xmargin) 684 continue; 685 686 if (pixel_image[i] & (1 << k)) 687 *(addr + j) = (*(addr + j) == fg) ? bg : fg; 688 } 689 addr += (sc->sc_stride/4); 690 } 691 692 return (0); 693} 694 695/* 696 * Define the syscons nexus device attachment 697 */ 698static void 699ps3fb_scidentify(driver_t *driver, device_t parent) 700{ 701 device_t child; 702 703 /* 704 * Add with a priority guaranteed to make it last on 705 * the device list 706 */ 707 if (strcmp(installed_platform(), "ps3") == 0) 708 child = BUS_ADD_CHILD(parent, INT_MAX, SC_DRIVER_NAME, 0); 709} 710 711static int 712ps3fb_scprobe(device_t dev) 713{ 714 int error; 715 716 if (strcmp(installed_platform(), "ps3") != 0) 717 return (ENXIO); 718 719 device_set_desc(dev, "System console"); 720 721 error = sc_probe_unit(device_get_unit(dev), 722 device_get_flags(dev) | SC_AUTODETECT_KBD); 723 if (error != 0) 724 return (error); 725 726 /* This is a fake device, so make sure we added it ourselves */ 727 return (BUS_PROBE_NOWILDCARD); 728} 729 730static int 731ps3fb_scattach(device_t dev) 732{ 733 return (sc_attach_unit(device_get_unit(dev), 734 device_get_flags(dev) | SC_AUTODETECT_KBD)); 735} 736 737static device_method_t ps3fb_sc_methods[] = { 738 DEVMETHOD(device_identify, ps3fb_scidentify), 739 DEVMETHOD(device_probe, ps3fb_scprobe), 740 DEVMETHOD(device_attach, ps3fb_scattach), 741 { 0, 0 } 742}; 743 744static driver_t ps3fb_sc_driver = { 745 SC_DRIVER_NAME, 746 ps3fb_sc_methods, 747 sizeof(sc_softc_t), 748}; 749 750static devclass_t sc_devclass; 751 752DRIVER_MODULE(ps3fb, nexus, ps3fb_sc_driver, sc_devclass, 0, 0); 753 754/* 755 * Define a stub keyboard driver in case one hasn't been 756 * compiled into the kernel 757 */ 758#include <sys/kbio.h> 759#include <dev/kbd/kbdreg.h> 760 761static int dummy_kbd_configure(int flags); 762 763keyboard_switch_t ps3dummysw; 764 765static int 766dummy_kbd_configure(int flags) 767{ 768 769 return (0); 770} 771KEYBOARD_DRIVER(ps3dummy, ps3dummysw, dummy_kbd_configure); 772 | |