[BACK]Return to xboxlcd.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / i386 / xbox

Annotation of src/sys/arch/i386/xbox/xboxlcd.c, Revision 1.2.6.3

1.2.6.3 ! yamt        1: /*     $NetBSD: xboxlcd.c,v 1.2.6.2 2008/01/21 09:37:17 yamt Exp $     */
1.2.6.2   yamt        2:
                      3: /*-
                      4:  * Copyright (c) 2006 Andrew Gillham
                      5:  * All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  * 3. The name of the author may not be used to endorse or promote products
                     16:  *    derived from this software without specific prior written permission
                     17:  *
                     18:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     19:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     20:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     21:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     22:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     23:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     24:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     25:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     26:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     27:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     28:  *
                     29:  */
                     30:
                     31: /*
                     32:  *  Driver for Xecuter X3 LCD add-on
                     33:  */
1.2.6.3 ! yamt       34:
        !            35: #include <sys/cdefs.h>
        !            36: __KERNEL_RCSID(0, "$NetBSD: xboxlcd.c,v 1.2.6.2 2008/01/21 09:37:17 yamt Exp $");
        !            37:
1.2.6.2   yamt       38: #include <sys/param.h>
                     39: #include <sys/systm.h>
                     40: #include <sys/kernel.h>
                     41: #include <machine/bus.h>
                     42: #include <machine/xbox.h>
                     43: #include <machine/pio.h>
                     44:
                     45: void xbox_lcd_init(void)
                     46: {
                     47:        outb(X3LCD_O_DAT, 0);
                     48:        outb(X3LCD_O_CMD, 0);
                     49:        outb(X3LCD_O_DIR_DAT, 0xFF);
                     50:        outb(X3LCD_O_DIR_CMD, 0x07);
                     51:
                     52:        xbox_lcd_output(X3LCD_FUNC_SET | X3LCD_DL_FLAG, X3LCD_INI);
                     53:        delay(50000);
                     54:        xbox_lcd_output(X3LCD_FUNC_SET | X3LCD_DL_FLAG, X3LCD_INI);
                     55:        delay(50000);
                     56:        xbox_lcd_output(X3LCD_FUNC_SET | X3LCD_DL_FLAG, X3LCD_INI);
                     57:        delay(50000);
                     58:        xbox_lcd_output(X3LCD_FUNC_SET, X3LCD_INI);
                     59:        delay(50000);
                     60:        xbox_lcd_output(X3LCD_FUNC_SET | X3LCD_DL_FLAG | X3LCD_N_FLAG, X3LCD_CMD);
                     61:        delay(50000);
                     62:        xbox_lcd_output(X3LCD_CONTROL | X3LCD_D_FLAG, X3LCD_CMD);
                     63:        delay(50000);
                     64:        xbox_lcd_output(X3LCD_CLEAR, X3LCD_CMD);
                     65:        delay(50000);
                     66:        xbox_lcd_output(X3LCD_ENTRY_MODE | X3LCD_ID_FLAG, X3LCD_CMD);
                     67:        delay(50000);
                     68:
                     69:        /* xbox_lcd_setpos(0,0); */
                     70:
                     71:        outb(X3LCD_O_LIGHT, 81);
                     72:        delay(50000);
                     73: }
                     74:
                     75: void xbox_lcd_output(unsigned char data, unsigned char command)
                     76: {
                     77:        unsigned char cmd = 0;
                     78:        int s;
                     79:
                     80:        if (command & X3LCD_DAT)
                     81:        {
                     82:                cmd |= X3LCD_DISPCON_RS;
                     83:        }
                     84:
                     85:        /* output upper nibble of data */
                     86:        /* outb(X3LCD_O_DAT, data & 0xF0); */
                     87: /*
                     88:        outb(X3LCD_O_DAT, data);
                     89:        outb(X3LCD_O_CMD, cmd);
                     90:        outb(X3LCD_O_CMD, X3LCD_DISPCON_E | cmd);
                     91:        outb(X3LCD_O_CMD, cmd);
                     92: */
                     93:
                     94:        s = splhigh();
                     95:        /* only if not init command */
                     96:        if ((command & X3LCD_INI) == 0)
                     97:        {
                     98:                /* output lower nibble of data */
                     99:                /* outb(X3LCD_O_DAT, (data << 4) & 0xF0); */
                    100:                outb(X3LCD_O_DAT, data);
                    101:                outb(X3LCD_O_CMD, cmd);
                    102:                outb(X3LCD_O_CMD, X3LCD_DISPCON_E | cmd);
                    103:                outb(X3LCD_O_CMD, cmd);
                    104:        }
                    105:        splx(s);
                    106:        delay(30000);
                    107: }
                    108:
                    109: void xbox_lcd_writestring(char *lcdstring)
                    110: {
                    111:        unsigned char i;
                    112:        do {
                    113:                i = *lcdstring;
                    114:                if ( i == 0x00)
                    115:                        break;
                    116:
                    117:                xbox_lcd_output(i, X3LCD_DAT);
                    118:                i = *lcdstring++;
                    119:        } while(1);
                    120: }
                    121:
                    122:
                    123: void xbox_lcd_writetext(const char *lcdtext)
                    124: {
                    125:        unsigned char i;
                    126:        while ((i = *lcdtext++)) {
                    127:                if ((i > 31) && (i < 128)) {
                    128:                        xbox_lcd_output(i, X3LCD_DAT);
                    129:                }
                    130:        }
                    131: }
                    132:
                    133: void xbox_lcd_putchar(unsigned char data)
                    134: {
                    135:        if ((data >= ' ') && (data <= '~')) {
                    136:                xbox_lcd_output(data, X3LCD_DAT);
                    137:        }
                    138: }
                    139:
                    140: void xbox_lcd_setpos(unsigned int pos, unsigned int line)
                    141: {
                    142:        xbox_lcd_output(X3LCD_DDRAM_SET | 0, X3LCD_CMD);
                    143: }
                    144:

CVSweb <webmaster@jp.NetBSD.org>