Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Pull the latest OpenBSD sti(4) changes for bitmap...



details:   https://anonhg.NetBSD.org/src/rev/696e65df882f
branches:  trunk
changeset: 948263:696e65df882f
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Wed Dec 23 08:34:35 2020 +0000

description:
Pull the latest OpenBSD sti(4) changes for bitmap framebuffer support.

- bitmap and colormap ops based on old HP ngle X11 driver:
  http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/dev/ic/sti.c#rev1.76
  > Work-in-progress support for non-accelerated X11 on *some* sti(4)
  > frame buffers; based upon the old HP ngle X11 driver.
  > Currently limited to CRX (720/735/750), Timber (710, old 715),
  > Artist (712, 715) and EG (B-series), however the
  > colormap isn't set up correctly on Timber and EG yet.
  >
  > Joint work with Artem Falcon, now in good enough shape to be worked further
  > in the tree.
- misc other cosmetic changes to reduce diffs

No particular comments on port-hp300@ and port-hppa@:
 https://mail-index.netbsd.org/port-hp300/2020/12/19/msg000184.html
 https://mail-index.netbsd.org/port-hp300/2020/12/20/msg000185.html

The MD hp300 attachment for SGC CRX (A1659-66001) will be committed
separately.

diffstat:

 sys/dev/ic/sti.c    |  528 ++++++++++++++++++++++++++++++++++++++++-----------
 sys/dev/ic/stivar.h |   21 +-
 2 files changed, 427 insertions(+), 122 deletions(-)

diffs (truncated from 806 to 300 lines):

diff -r 08ea2e1cd1e1 -r 696e65df882f sys/dev/ic/sti.c
--- a/sys/dev/ic/sti.c  Wed Dec 23 08:17:01 2020 +0000
+++ b/sys/dev/ic/sti.c  Wed Dec 23 08:34:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sti.c,v 1.22 2020/09/05 16:30:11 riastradh Exp $       */
+/*     $NetBSD: sti.c,v 1.23 2020/12/23 08:34:35 tsutsui Exp $ */
 
 /*     $OpenBSD: sti.c,v 1.61 2009/09/05 14:09:35 miod Exp $   */
 
@@ -31,11 +31,11 @@
  * TODO:
  *     call sti procs asynchronously;
  *     implement console scroll-back;
- *     X11 support.
+ *     X11 support on more models.
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.22 2020/09/05 16:30:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.23 2020/12/23 08:34:35 tsutsui Exp $");
 
 #include "wsdisplay.h"
 
@@ -80,32 +80,32 @@
 int  sti_alloc_attr(void *, int, int, int, long *);
 
 struct wsdisplay_emulops sti_emulops = {
-       sti_cursor,
-       sti_mapchar,
-       sti_putchar,
-       sti_copycols,
-       sti_erasecols,
-       sti_copyrows,
-       sti_eraserows,
-       sti_alloc_attr
+       .cursor = sti_cursor,
+       .mapchar = sti_mapchar,
+       .putchar = sti_putchar,
+       .copycols = sti_copycols,
+       .erasecols = sti_erasecols,
+       .copyrows = sti_copyrows,
+       .eraserows = sti_eraserows,
+       .allocattr = sti_alloc_attr
 };
 
 const struct wsdisplay_accessops sti_accessops = {
-       sti_ioctl,
-       sti_mmap,
-       sti_alloc_screen,
-       sti_free_screen,
-       sti_show_screen,
-       sti_load_font
+       .ioctl = sti_ioctl,
+       .mmap = sti_mmap,
+       .alloc_screen = sti_alloc_screen,
+       .free_screen = sti_free_screen,
+       .show_screen = sti_show_screen,
+       .load_font = sti_load_font
 };
 
 enum sti_bmove_funcs {
        bmf_clear, bmf_copy, bmf_invert, bmf_underline
 };
 
-int    sti_inqcfg(struct sti_screen *, struct sti_inqconfout *);
 void   sti_bmove(struct sti_screen *, int, int, int, int, int, int,
            enum sti_bmove_funcs);
+int    sti_inqcfg(struct sti_screen *, struct sti_inqconfout *);
 int    sti_setcment(struct sti_screen *, u_int, u_char, u_char, u_char);
 
 struct sti_screen *sti_attach_screen(struct sti_softc *, int);
@@ -118,6 +118,15 @@
            bus_space_handle_t, bus_addr_t *, u_int);
 int    sti_screen_setup(struct sti_screen *, int);
 
+int    ngle_default_putcmap(struct sti_screen *, u_int, u_int);
+
+#ifndef SMALL_KERNEL
+void   ngle_artist_setupfb(struct sti_screen *);
+void   ngle_elk_setupfb(struct sti_screen *);
+void   ngle_timber_setupfb(struct sti_screen *);
+int    ngle_putcmap(struct sti_screen *, u_int, u_int);
+#endif
+
 #if NSTI_PCI > 0
 #define        STI_ENABLE_ROM(sc) \
 do { \
@@ -210,51 +219,52 @@
        /*
         * Get ROM header and code function pointers.
         */
+
        dd = &rom->rom_dd;
        rom->rom_devtype = bus_space_read_1(memt, romh, 3);
        if (rom->rom_devtype == STI_DEVTYPE1) {
-               dd->dd_type  = bus_space_read_1(memt, romh, 0x03);
-               dd->dd_nmon  = bus_space_read_1(memt, romh, 0x07);
-               dd->dd_grrev = bus_space_read_1(memt, romh, 0x0b);
-               dd->dd_lrrev = bus_space_read_1(memt, romh, 0x0f);
-               dd->dd_grid[0] = parseword(0x10);
-               dd->dd_grid[1] = parseword(0x20);
-               dd->dd_fntaddr = parseword(0x30) & ~3;
-               dd->dd_maxst   = parseword(0x40);
-               dd->dd_romend  = parseword(0x50) & ~3;
-               dd->dd_reglst  = parseword(0x60) & ~3;
-               dd->dd_maxreent= parseshort(0x70);
-               dd->dd_maxtimo = parseshort(0x78);
-               dd->dd_montbl  = parseword(0x80) & ~3;
-               dd->dd_udaddr  = parseword(0x90) & ~3;
-               dd->dd_stimemreq=parseword(0xa0);
-               dd->dd_udsize  = parseword(0xb0);
-               dd->dd_pwruse  = parseshort(0xc0);
-               dd->dd_bussup  = bus_space_read_1(memt, romh, 0xcb);
-               dd->dd_ebussup = bus_space_read_1(memt, romh, 0xcf);
-               dd->dd_altcodet= bus_space_read_1(memt, romh, 0xd3);
-               dd->dd_eddst[0]= bus_space_read_1(memt, romh, 0xd7);
-               dd->dd_eddst[1]= bus_space_read_1(memt, romh, 0xdb);
-               dd->dd_eddst[2]= bus_space_read_1(memt, romh, 0xdf);
-               dd->dd_cfbaddr = parseword(0xe0) & ~3;
+               dd->dd_type      = bus_space_read_1(memt, romh, 0x03);
+               dd->dd_nmon      = bus_space_read_1(memt, romh, 0x07);
+               dd->dd_grrev     = bus_space_read_1(memt, romh, 0x0b);
+               dd->dd_lrrev     = bus_space_read_1(memt, romh, 0x0f);
+               dd->dd_grid[0]   = parseword(0x10);
+               dd->dd_grid[1]   = parseword(0x20);
+               dd->dd_fntaddr   = parseword(0x30) & ~3;
+               dd->dd_maxst     = parseword(0x40);
+               dd->dd_romend    = parseword(0x50) & ~3;
+               dd->dd_reglst    = parseword(0x60) & ~3;
+               dd->dd_maxreent  = parseshort(0x70);
+               dd->dd_maxtimo   = parseshort(0x78);
+               dd->dd_montbl    = parseword(0x80) & ~3;
+               dd->dd_udaddr    = parseword(0x90) & ~3;
+               dd->dd_stimemreq = parseword(0xa0);
+               dd->dd_udsize    = parseword(0xb0);
+               dd->dd_pwruse    = parseshort(0xc0);
+               dd->dd_bussup    = bus_space_read_1(memt, romh, 0xcb);
+               dd->dd_ebussup   = bus_space_read_1(memt, romh, 0xcf);
+               dd->dd_altcodet  = bus_space_read_1(memt, romh, 0xd3);
+               dd->dd_eddst[0]  = bus_space_read_1(memt, romh, 0xd7);
+               dd->dd_eddst[1]  = bus_space_read_1(memt, romh, 0xdb);
+               dd->dd_eddst[2]  = bus_space_read_1(memt, romh, 0xdf);
+               dd->dd_cfbaddr   = parseword(0xe0) & ~3;
 
                codebase <<= 2;
-               dd->dd_pacode[0x0] = parseword(codebase + 0x00) & ~3;
-               dd->dd_pacode[0x1] = parseword(codebase + 0x10) & ~3;
-               dd->dd_pacode[0x2] = parseword(codebase + 0x20) & ~3;
-               dd->dd_pacode[0x3] = parseword(codebase + 0x30) & ~3;
-               dd->dd_pacode[0x4] = parseword(codebase + 0x40) & ~3;
-               dd->dd_pacode[0x5] = parseword(codebase + 0x50) & ~3;
-               dd->dd_pacode[0x6] = parseword(codebase + 0x60) & ~3;
-               dd->dd_pacode[0x7] = parseword(codebase + 0x70) & ~3;
-               dd->dd_pacode[0x8] = parseword(codebase + 0x80) & ~3;
-               dd->dd_pacode[0x9] = parseword(codebase + 0x90) & ~3;
-               dd->dd_pacode[0xa] = parseword(codebase + 0xa0) & ~3;
-               dd->dd_pacode[0xb] = parseword(codebase + 0xb0) & ~3;
-               dd->dd_pacode[0xc] = parseword(codebase + 0xc0) & ~3;
-               dd->dd_pacode[0xd] = parseword(codebase + 0xd0) & ~3;
-               dd->dd_pacode[0xe] = parseword(codebase + 0xe0) & ~3;
-               dd->dd_pacode[0xf] = parseword(codebase + 0xf0) & ~3;
+               dd->dd_pacode[0x0] = parseword(codebase + 0x000) & ~3;
+               dd->dd_pacode[0x1] = parseword(codebase + 0x010) & ~3;
+               dd->dd_pacode[0x2] = parseword(codebase + 0x020) & ~3;
+               dd->dd_pacode[0x3] = parseword(codebase + 0x030) & ~3;
+               dd->dd_pacode[0x4] = parseword(codebase + 0x040) & ~3;
+               dd->dd_pacode[0x5] = parseword(codebase + 0x050) & ~3;
+               dd->dd_pacode[0x6] = parseword(codebase + 0x060) & ~3;
+               dd->dd_pacode[0x7] = parseword(codebase + 0x070) & ~3;
+               dd->dd_pacode[0x8] = parseword(codebase + 0x080) & ~3;
+               dd->dd_pacode[0x9] = parseword(codebase + 0x090) & ~3;
+               dd->dd_pacode[0xa] = parseword(codebase + 0x0a0) & ~3;
+               dd->dd_pacode[0xb] = parseword(codebase + 0x0b0) & ~3;
+               dd->dd_pacode[0xc] = parseword(codebase + 0x0c0) & ~3;
+               dd->dd_pacode[0xd] = parseword(codebase + 0x0d0) & ~3;
+               dd->dd_pacode[0xe] = parseword(codebase + 0x0e0) & ~3;
+               dd->dd_pacode[0xf] = parseword(codebase + 0x0f0) & ~3;
        } else {        /* STI_DEVTYPE4 */
                bus_space_read_region_stream_4(memt, romh, 0, (uint32_t *)dd,
                    sizeof(*dd) / 4);
@@ -288,7 +298,7 @@
         * Note there could be fewer than STI_END pointer entries
         * populated, especially on older devices.
         */
-       for (i = STI_END; !dd->dd_pacode[i]; i--)
+       for (i = STI_END; dd->dd_pacode[i] == 0; i--)
                ;
 
        size = dd->dd_pacode[i] - dd->dd_pacode[STI_BEGIN];
@@ -300,13 +310,12 @@
                return EINVAL;
        }
 
-       DPRINTF(("code size %x/%x\n", size, round_page(size)));
-
        if (!(rom->rom_code = uvm_km_alloc(kernel_map, round_page(size), 0,
            UVM_KMF_WIRED))) {
                aprint_error(": cannot allocate %u bytes for code\n", size);
                return ENOMEM;
        }
+       DPRINTF(("code=0x%lx[%x]\n", rom->rom_code, size));
 
        /*
         * Copy code into memory and make it executable.
@@ -322,8 +331,7 @@
 
                for (addr = dd->dd_pacode[STI_BEGIN], eaddr = addr + size * 4;
                    addr < eaddr; addr += 4 ) {
-                       *p++ = bus_space_read_4(memt, romh, addr)
-                           & 0xff;
+                       *p++ = bus_space_read_4(memt, romh, addr) & 0xff;
                }
        } else {        /* STI_DEVTYPE4 */
                bus_space_read_region_stream_4(memt, romh,
@@ -349,26 +357,27 @@
        (dd->dd_pacode[(i)] == 0 ? 0 : \
            (rom->rom_code + (dd->dd_pacode[(i)] - dd->dd_pacode[0]) /  \
            (rom->rom_devtype == STI_DEVTYPE1 ? 4 : 1)))
-       rom->init       = (sti_init_t)  O(STI_INIT_GRAPH);
-       rom->mgmt       = (sti_mgmt_t)  O(STI_STATE_MGMT);
-       rom->unpmv      = (sti_unpmv_t) O(STI_FONT_UNPMV);
-       rom->blkmv      = (sti_blkmv_t) O(STI_BLOCK_MOVE);
-       rom->test       = (sti_test_t)  O(STI_SELF_TEST);
-       rom->exhdl      = (sti_exhdl_t) O(STI_EXCEP_HDLR);
+
+       rom->init       = (sti_init_t)O(STI_INIT_GRAPH);
+       rom->mgmt       = (sti_mgmt_t)O(STI_STATE_MGMT);
+       rom->unpmv      = (sti_unpmv_t)O(STI_FONT_UNPMV);
+       rom->blkmv      = (sti_blkmv_t)O(STI_BLOCK_MOVE);
+       rom->test       = (sti_test_t)O(STI_SELF_TEST);
+       rom->exhdl      = (sti_exhdl_t)O(STI_EXCEP_HDLR);
        rom->inqconf    = (sti_inqconf_t)O(STI_INQ_CONF);
        rom->scment     = (sti_scment_t)O(STI_SCM_ENT);
-       rom->dmac       = (sti_dmac_t)  O(STI_DMA_CTRL);
-       rom->flowc      = (sti_flowc_t) O(STI_FLOW_CTRL);
+       rom->dmac       = (sti_dmac_t)O(STI_DMA_CTRL);
+       rom->flowc      = (sti_flowc_t)O(STI_FLOW_CTRL);
        rom->utiming    = (sti_utiming_t)O(STI_UTIMING);
-       rom->pmgr       = (sti_pmgr_t)  O(STI_PROC_MGR);
-       rom->util       = (sti_util_t)  O(STI_UTIL);
+       rom->pmgr       = (sti_pmgr_t)O(STI_PROC_MGR);
+       rom->util       = (sti_util_t)O(STI_UTIL);
 
 #undef O
+
        /*
         * Set colormap entry is not implemented until 8.04, so force
         * a NULL pointer here.
         */
-
        if (dd->dd_grrev < STI_REVISION(8, 4)) {
                rom->scment = NULL;
        }
@@ -388,7 +397,6 @@
        bus_addr_t *bases = rom->bases;
        struct sti_dd *dd = &rom->rom_dd;
        struct sti_cfg *cc = &scr->scr_cfg;
-       bus_space_handle_t bh;
        struct sti_region regions[STI_REGION_MAX], *r;
        u_int regno, regcnt;
        bus_addr_t addr;
@@ -449,14 +457,14 @@
                        continue;
                }
 
-               /* XXXNH BUS_SPACE_MAP_CACHEABLE */
                if (bus_space_map(memt, addr, r->length << PGSHIFT,
-                   r->cache ? BUS_SPACE_MAP_CACHEABLE : 0, &bh)) {
+                   BUS_SPACE_MAP_LINEAR | (r->cache ?
+                   BUS_SPACE_MAP_CACHEABLE : 0), &rom->regh[regno]) != 0) {
+                       rom->regh[regno] = romh;        /* XXX */
                        DPRINTF((" - already mapped region\n"));
                } else {
-
-                       /* XXX should use bus_space_vaddr */
-                       addr = (bus_addr_t)bh;
+                       addr = (bus_addr_t)
+                           bus_space_vaddr(memt, rom->regh[regno]);
                        if (regno == 1) {
                                DPRINTF((" - fb"));
                                scr->fbaddr = addr;
@@ -616,6 +624,73 @@
        scr->scr_screenlist.nscreens = 1;
        scr->scr_screenlist.screens = scr->scr_scrlist;
 
+#ifndef SMALL_KERNEL
+       /*
+        * Decide which board-specific routines to use.
+        */
+
+       switch (dd->dd_grid[0]) {
+       case STI_DD_CRX:
+               scr->setupfb = ngle_elk_setupfb;
+               scr->putcmap = ngle_putcmap;
+
+               scr->reg10_value = 0x13601000;
+               if (scr->scr_bpp > 8)
+                       scr->reg12_value = NGLE_BUFF1_CMAP3;
+               else
+                       scr->reg12_value = NGLE_BUFF1_CMAP0;



Home | Main Index | Thread Index | Old Index