Index: sys/arch/evbarm/rpi/rpi_machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/evbarm/rpi/rpi_machdep.c,v retrieving revision 1.54 diff -u -r1.54 rpi_machdep.c --- sys/arch/evbarm/rpi/rpi_machdep.c 4 Oct 2014 13:05:57 -0000 1.54 +++ sys/arch/evbarm/rpi/rpi_machdep.c 4 Oct 2014 13:22:13 -0000 @@ -171,6 +171,8 @@ /* Smallest amount of RAM start.elf could give us. */ #define RPI_MINIMUM_SPLIT (128U * 1024 * 1024) +#define RPI_FWREV_HWCURSOR 1390809622 + static struct __aligned(16) { struct vcprop_buffer_hdr vb_hdr; struct vcprop_tag_fwrev vbt_fwrev; @@ -385,17 +387,16 @@ static int rpi_video_on = WSDISPLAYIO_VIDEO_ON; -#if defined(RPI_HWCURSOR) #define CURSOR_BITMAP_SIZE (64 * 8) #define CURSOR_ARGB_SIZE (64 * 64 * 4) static uint32_t hcursor = 0; static bus_addr_t pcursor = 0; static uint32_t *cmem = NULL; static int cursor_x = 0, cursor_y = 0, hot_x = 0, hot_y = 0, cursor_on = 0; +static int cursor_x_min, cursor_x_max, cursor_y_min, cursor_y_max; static uint32_t cursor_cmap[4]; static uint8_t cursor_mask[8 * 64], cursor_bitmap[8 * 64]; #endif -#endif static void @@ -403,7 +404,7 @@ { bus_space_tag_t iot = &bcm2835_bs_tag; bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(BCM2835_ARMMBOX_BASE); - uint32_t res; + uint32_t res[BCM2835_MBOX_NUMCHANNELS]; bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANPM, ( #if (NSDHC > 0) @@ -426,7 +427,7 @@ bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC, KERN_VTOPHYS(&vb)); - bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res); + bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, res); /* * No need to invalid the cache as the memory has never been referenced @@ -463,16 +464,16 @@ #ifdef VERBOSE_INIT_ARM if (vcprop_tag_success_p(&vb.vbt_fwrev.tag)) - printf("%s: firmware rev %x\n", __func__, + printf("%s: firmware rev %u\n", __func__, vb.vbt_fwrev.rev); if (vcprop_tag_success_p(&vb.vbt_macaddr.tag)) printf("%s: mac-address %llx\n", __func__, vb.vbt_macaddr.addr); if (vcprop_tag_success_p(&vb.vbt_boardmodel.tag)) - printf("%s: board model %x\n", __func__, + printf("%s: board model %u\n", __func__, vb.vbt_boardmodel.model); if (vcprop_tag_success_p(&vb.vbt_boardrev.tag)) - printf("%s: board rev %x\n", __func__, + printf("%s: board rev %u\n", __func__, vb.vbt_boardrev.rev); if (vcprop_tag_success_p(&vb.vbt_serial.tag)) printf("%s: board serial %llx\n", __func__, @@ -831,47 +832,57 @@ } #if defined(RPI_HWCURSOR) - struct amba_attach_args *aaa = aux; - bus_space_handle_t hc; + if (vb.vbt_fwrev.rev >= RPI_FWREV_HWCURSOR) { +#else + if (/* CONSTCOND */ 0) { +#endif + + struct amba_attach_args *aaa = aux; + bus_space_handle_t hc; + + cursor_x_min = 0; + cursor_x_max = width-1; + cursor_y_min = 0; + cursor_y_max = height-1; + + hcursor = rpi_alloc_mem(CURSOR_ARGB_SIZE, PAGE_SIZE, + MEM_FLAG_L1_NONALLOCATING | MEM_FLAG_HINT_PERMALOCK); + pcursor = rpi_lock_mem(hcursor); - hcursor = rpi_alloc_mem(CURSOR_ARGB_SIZE, PAGE_SIZE, - MEM_FLAG_L1_NONALLOCATING | MEM_FLAG_HINT_PERMALOCK); - pcursor = rpi_lock_mem(hcursor); #ifdef RPI_IOCTL_DEBUG - printf("hcursor: %08x\n", hcursor); - printf("pcursor: %08x\n", (uint32_t)pcursor); - printf("fb: %08x\n", (uint32_t)vb_setfb.vbt_allocbuf.address); -#endif - if (bus_space_map(aaa->aaa_iot, pcursor, CURSOR_ARGB_SIZE, - BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE, &hc) != 0) { - printf("couldn't map cursor memory\n"); - } else { - int i, j, k; - - cmem = bus_space_vaddr(aaa->aaa_iot, hc); - k = 0; - for (j = 0; j < 64; j++) { - for (i = 0; i < 64; i++) { - cmem[i + k] = - ((i & 8) ^ (j & 8)) ? 0xa0ff0000 : 0xa000ff00; + printf("hcursor: %08x\n", hcursor); + printf("pcursor: %08x\n", (uint32_t)pcursor); + printf("fb: %08x\n", (uint32_t)vb_setfb.vbt_allocbuf.address); +#endif + if (bus_space_map(aaa->aaa_iot, pcursor, CURSOR_ARGB_SIZE, + BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE, &hc) != 0) { + printf("couldn't map cursor memory\n"); + } else { + int i, j, k; + + cmem = bus_space_vaddr(aaa->aaa_iot, hc); + k = 0; + for (j = 0; j < 64; j++) { + for (i = 0; i < 64; i++) { + cmem[i + k] = + ((i & 8) ^ (j & 8)) ? 0xa0ff0000 : 0xa000ff00; + } + k += 64; } - k += 64; - } - cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE); - rpi_fb_initcursor(pcursor, 0, 0); + + cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE); + rpi_fb_initcursor(pcursor, 0, 0); + } + #ifdef RPI_IOCTL_DEBUG rpi_fb_movecursor(600, 400, 1); #else rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); #endif - } -#endif - + } return true; } - -#if defined(RPI_HWCURSOR) static int rpi_fb_do_cursor(struct wsdisplay_cursor *cur) { @@ -887,14 +898,22 @@ if (cur->which & WSDISPLAY_CURSOR_DOHOT) { hot_x = cur->hot.x; + if (hot_x < 0) hot_x = 0; + if (hot_x > 63) hot_x = 63; hot_y = cur->hot.y; + if (hot_y < 0) hot_y = 0; + if (hot_y > 63) hot_y = 63; pos = 1; shape = 1; } if (cur->which & WSDISPLAY_CURSOR_DOPOS) { cursor_x = cur->pos.x; + if (cursor_x < cursor_x_min) cursor_x = cursor_x_min; + if (cursor_x > cursor_x_max) cursor_x = cursor_x_max; cursor_y = cur->pos.y; + if (cursor_y < cursor_y_min) cursor_y = cursor_y_min; + if (cursor_y > cursor_y_max) cursor_y = cursor_y_max; pos = 1; } if (cur->which & WSDISPLAY_CURSOR_DOCMAP) { @@ -941,7 +960,6 @@ } return 0; } -#endif static int rpi_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l) @@ -955,20 +973,23 @@ return 0; rpi_video_on = d; rpi_fb_set_video(d); -#if defined(RPI_HWCURSOR) - rpi_fb_movecursor(cursor_x, cursor_y, - d ? cursor_on : 0); -#endif + + if (hcursor) { + rpi_fb_movecursor(cursor_x, cursor_y, + d ? cursor_on : 0); + } } return 0; case WSDISPLAYIO_GVIDEO: *(int *)data = rpi_video_on; return 0; -#if defined(RPI_HWCURSOR) case WSDISPLAYIO_GCURPOS: { struct wsdisplay_curpos *cp = (void *)data; + if (hcursor == 0) + return ENODEV; + cp->x = cursor_x; cp->y = cursor_y; } @@ -977,6 +998,9 @@ { struct wsdisplay_curpos *cp = (void *)data; + if (hcursor == 0) + return ENODEV; + cursor_x = cp->x; cursor_y = cp->y; rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); @@ -986,6 +1010,9 @@ { struct wsdisplay_curpos *cp = (void *)data; + if (hcursor == 0) + return ENODEV; + cp->x = 64; cp->y = 64; } @@ -994,9 +1021,11 @@ { struct wsdisplay_cursor *cursor = (void *)data; + if (hcursor == 0) + return ENODEV; + return rpi_fb_do_cursor(cursor); } -#endif default: return EPASSTHROUGH; } @@ -1082,7 +1111,7 @@ NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READONLY|CTLFLAG_HEX, + CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_INT, "firmware_revision", NULL, NULL, 0, &vb.vbt_fwrev.rev, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL);