Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcarm Add support for jornada720's framebuffer.



details:   https://anonhg.NetBSD.org/src/rev/22249705313a
branches:  trunk
changeset: 510554:22249705313a
user:      toshii <toshii%NetBSD.org@localhost>
date:      Fri Jun 01 02:51:03 2001 +0000

description:
Add support for jornada720's framebuffer.

The functionality is almost same as bivideo, and hardware rasops and
power saving are not yet supported.

diffstat:

 sys/arch/hpcarm/conf/JORNADA720   |    9 +-
 sys/arch/hpcarm/conf/files.hpcarm |    6 +-
 sys/arch/hpcarm/dev/sed_saip.c    |  706 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 718 insertions(+), 3 deletions(-)

diffs (truncated from 759 to 300 lines):

diff -r 7e389904019a -r 22249705313a sys/arch/hpcarm/conf/JORNADA720
--- a/sys/arch/hpcarm/conf/JORNADA720   Fri Jun 01 02:42:26 2001 +0000
+++ b/sys/arch/hpcarm/conf/JORNADA720   Fri Jun 01 02:51:03 2001 +0000
@@ -1,11 +1,11 @@
-#      $NetBSD: JORNADA720,v 1.4 2001/05/23 16:52:34 toshii Exp $
+#      $NetBSD: JORNADA720,v 1.5 2001/06/01 02:51:03 toshii Exp $
 #
 #      JORNADA -- Windows-CE based jornada 720
 #
 
 include        "arch/hpcarm/conf/std.hpcarm"
 
-#ident                 "GENERIC-$Revision: 1.4 $"
+#ident                 "GENERIC-$Revision: 1.5 $"
 
 # estimated number of users
 maxusers       32
@@ -195,6 +195,11 @@
 
 options                FRAMEBUF_HW_BASE="0x48200000"
 
+# physical console
+sed0           at saip?
+hpcfb*         at sed?
+wsdisplay*     at hpcfb?
+
 pseudo-device  loop    1               # network loopback
 pseudo-device  bpfilter 8              # packet filter
 pseudo-device  sl      2               # CSLIP
diff -r 7e389904019a -r 22249705313a sys/arch/hpcarm/conf/files.hpcarm
--- a/sys/arch/hpcarm/conf/files.hpcarm Fri Jun 01 02:42:26 2001 +0000
+++ b/sys/arch/hpcarm/conf/files.hpcarm Fri Jun 01 02:51:03 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hpcarm,v 1.17 2001/05/30 14:39:19 toshii Exp $
+#      $NetBSD: files.hpcarm,v 1.18 2001/06/01 02:51:03 toshii Exp $
 #
 # First try for arm-specific configuration info
 #
@@ -91,6 +91,10 @@
 attach salcd at saip
 file   arch/hpcarm/sa11x0/sa11x0_lcd.c         salcd
 
+device sed: hpcfbif
+attach sed at saip
+file   arch/hpcarm/dev/sed_saip.c              sed
+
 #
 # Workstation Console
 #
diff -r 7e389904019a -r 22249705313a sys/arch/hpcarm/dev/sed_saip.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcarm/dev/sed_saip.c    Fri Jun 01 02:51:03 2001 +0000
@@ -0,0 +1,706 @@
+/*     $NetBSD: sed_saip.c,v 1.1 2001/06/01 02:51:03 toshii Exp $      */
+
+/*-
+ * Copyright (c) 1999-2001
+ *         Shin Takemura and PocketBSD Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the PocketBSD project
+ *     and its contributors.
+ * 4. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#define FBDEBUG
+static const char _copyright[] __attribute__ ((unused)) =
+    "Copyright (c) 1999 Shin Takemura.  All rights reserved.";
+static const char _rcsid[] __attribute__ ((unused)) =
+    "$NetBSD: sed_saip.c,v 1.1 2001/06/01 02:51:03 toshii Exp $";
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/buf.h>
+#include <sys/ioctl.h>
+#include <sys/reboot.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <machine/bus.h>
+#include <machine/autoconf.h>
+#include <machine/bootinfo.h>
+#include <machine/config_hook.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+
+#include <dev/rasops/rasops.h>
+
+#include <dev/hpc/hpcfbvar.h>
+#include <dev/hpc/hpcfbio.h>
+#include <dev/hpc/hpccmapvar.h>
+
+#define VPRINTF(arg)   do { if (bootverbose) printf arg; } while(0);
+
+/*
+ *  function prototypes
+ */
+int    sed1356match(struct device *, struct cfdata *, void *);
+void   sed1356attach(struct device *, struct device *, void *);
+int    sed1356_ioctl(void *, u_long, caddr_t, int, struct proc *);
+paddr_t        sed1356_mmap(void *, off_t, int);
+
+struct sed1356_softc {
+       struct device           sc_dev;
+       struct hpcfb_fbconf     sc_fbconf;
+       struct hpcfb_dspconf    sc_dspconf;
+
+       void                    *sc_powerhook;  /* power management hook */
+       int                     sc_powerstate;
+#define PWRSTAT_SUSPEND                (1<<0)
+#define PWRSTAT_VIDEOOFF       (1<<1)
+#define PWRSTAT_LCD            (1<<2)
+#define PWRSTAT_BACKLIGHT      (1<<3)
+#define PWRSTAT_ALL            (0xffffffff)
+       int                     sc_lcd_inited;
+#define BACKLIGHT_INITED       (1<<0)
+#define BRIGHTNESS_INITED      (1<<1)
+#define CONTRAST_INITED                (1<<2)
+       int                     sc_brightness;
+       int                     sc_brightness_save;
+       int                     sc_max_brightness;
+       int                     sc_contrast;
+       int                     sc_max_contrast;
+
+};
+
+extern struct bus_space sa11x0_bs_tag;
+
+static int sed1356_init(struct hpcfb_fbconf *);
+static void sed1356_power(int, void *);
+static void sed1356_update_powerstate(struct sed1356_softc *, int);
+void   sed1356_init_backlight(struct sed1356_softc *, int);
+void   sed1356_init_brightness(struct sed1356_softc *, int);
+void   sed1356_init_contrast(struct sed1356_softc *, int);
+void   sed1356_set_brightness(struct sed1356_softc *, int);
+void   sed1356_set_contrast(struct sed1356_softc *, int);
+
+#if defined __mips__ || defined __sh__ || defined __arm__
+#define __BTOP(x)              ((paddr_t)(x) >> PGSHIFT)
+#define __PTOB(x)              ((paddr_t)(x) << PGSHIFT)
+#else
+#error "define btop, ptob."
+#endif
+
+/*
+ *  static variables
+ */
+struct cfattach sed_ca = {
+       sizeof(struct sed1356_softc), sed1356match, sed1356attach,
+};
+struct hpcfb_accessops sed1356_ha = {
+       sed1356_ioctl, sed1356_mmap
+};
+
+static int console_flag = 0;
+static int attach_flag = 0;
+
+/*
+ *  function bodies
+ */
+int
+sed1356match(struct device *parent, struct cfdata *match, void *aux)
+{
+
+       /* XXX check version register */
+       return 1;
+}
+
+void
+sed1356attach(struct device *parent, struct device *self, void *aux)
+{
+       struct sed1356_softc *sc = (struct sed1356_softc *)self;
+       struct hpcfb_attach_args ha;
+
+       if (attach_flag) {
+               panic("%s(%d): sed1356 attached twice", __FILE__, __LINE__);
+       }
+       attach_flag = 1;
+
+       if (sed1356_init(&sc->sc_fbconf) != 0) {
+               /* just return so that hpcfb will not be attached */
+               return;
+       }
+
+       printf("%s: Epson SED1356", sc->sc_dev.dv_xname);
+       if (console_flag) {
+               printf(", console");
+       }
+       printf("\n");
+       printf("%s: framebuffer address: 0x%08lx\n", 
+               sc->sc_dev.dv_xname, (u_long)bootinfo->fb_addr);
+
+       /* Add a suspend hook to power saving */
+       sc->sc_powerstate = 0;
+       sc->sc_powerhook = powerhook_establish(sed1356_power, sc);
+       if (sc->sc_powerhook == NULL)
+               printf("%s: WARNING: unable to establish power hook\n",
+                       sc->sc_dev.dv_xname);
+
+       /* initialize backlight brightness and lcd contrast */
+       sc->sc_lcd_inited = 0;
+       sed1356_init_brightness(sc, 1);
+       sed1356_init_contrast(sc, 1);
+       sed1356_init_backlight(sc, 1);
+
+       ha.ha_console = console_flag;
+       ha.ha_accessops = &sed1356_ha;
+       ha.ha_accessctx = sc;
+       ha.ha_curfbconf = 0;
+       ha.ha_nfbconf = 1;
+       ha.ha_fbconflist = &sc->sc_fbconf;
+       ha.ha_curdspconf = 0;
+       ha.ha_ndspconf = 1;
+       ha.ha_dspconflist = &sc->sc_dspconf;
+
+       config_found(self, &ha, hpcfbprint);
+}
+
+int
+sed1356_getcnfb(struct hpcfb_fbconf *fb)
+{
+       console_flag = 1;
+
+       return sed1356_init(fb);
+}
+
+static int
+sed1356_init(struct hpcfb_fbconf *fb)
+{
+       /*
+        * get fb settings from bootinfo
+        */
+       if (bootinfo == NULL ||
+           bootinfo->fb_addr == 0 ||
+           bootinfo->fb_line_bytes == 0 ||
+           bootinfo->fb_width == 0 ||
+           bootinfo->fb_height == 0) {
+               printf("no frame buffer infomation.\n");
+               return (-1);
+       }
+
+       /* zero fill */
+       bzero(fb, sizeof(*fb));
+
+       fb->hf_conf_index       = 0;    /* configuration index          */
+       fb->hf_nconfs           = 1;    /* how many configurations      */
+       strcpy(fb->hf_name, "built-in video");
+                                       /* frame buffer name            */
+       strcpy(fb->hf_conf_name, "default");
+                                       /* configuration name           */
+       fb->hf_height           = bootinfo->fb_height;
+       fb->hf_width            = bootinfo->fb_width;
+       if (bus_space_map(&sa11x0_bs_tag, (bus_addr_t)bootinfo->fb_addr,
+                          bootinfo->fb_height * bootinfo->fb_line_bytes,
+                          0, &fb->hf_baseaddr)) {
+               printf("unable to map framebuffer\n");
+               return (-1);
+       }
+       fb->hf_offset           = (u_long)bootinfo->fb_addr -
+                                     __PTOB(__BTOP(bootinfo->fb_addr));
+                                       /* frame buffer start offset    */
+       fb->hf_bytes_per_line   = bootinfo->fb_line_bytes;
+       fb->hf_nplanes          = 1;
+       fb->hf_bytes_per_plane  = bootinfo->fb_height *
+                                       bootinfo->fb_line_bytes;
+
+       fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
+       fb->hf_access_flags |= HPCFB_ACCESS_WORD;
+       fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
+
+       switch (bootinfo->fb_type) {
+               /*
+                * gray scale
+                */
+       case BIFB_D4_M2L_F:



Home | Main Index | Thread Index | Old Index