1 /* $NetBSD: pxa2x0_lcd.h,v 1.1 2002/10/19 19:31:40 bsh Exp $ */ 2 /* 3 * Copyright (c) 2002 Genetec Corporation. All rights reserved. 4 * Written by Hiroyuki Bessho for Genetec Corporation. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed for the NetBSD Project by 17 * Genetec Corporation. 18 * 4. The name of Genetec Corporation may not be used to endorse or 19 * promote products derived from this software without specific prior 20 * written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 36 #ifndef _ARM_XSCALE_PXA2X0_LCD_H 37 #define _ARM_XSCALE_PXA2X0_LCD_H 38 39 #include <dev/rasops/rasops.h> 40 #include <machine/bus.h> 41 42 /* LCD Contoroller */ 43 44 struct lcd_dma_descriptor { 45 uint32_t fdadr; /* next frame descriptor */ 46 uint32_t fsadr; /* frame start address */ 47 uint32_t fidr; /* frame ID */ 48 uint32_t ldcmd; /* DMA command */ 49 #define LDCMD_PAL (1U<<26) /* Pallet buffer */ 50 #define LDCMD_SOFINT (1U<<22) /* Start of Frame interrupt */ 51 #define LDCMD_EOFINT (1U<<21) /* End of Frame interrupt */ 52 }; 53 54 55 struct pxa2x0_lcd_screen { 56 LIST_ENTRY(pxa2x0_lcd_screen) link; 57 58 /* Frame buffer */ 59 bus_dmamap_t dma; 60 bus_dma_segment_t segs[1]; 61 int nsegs; 62 size_t buf_size; 63 size_t map_size; 64 void *buf_va; 65 int depth; 66 67 /* DMA frame descriptor */ 68 struct lcd_dma_descriptor *dma_desc; 69 paddr_t dma_desc_pa; 70 71 /* rasterop */ 72 struct rasops_info rinfo; 73 }; 74 75 struct pxa2x0_lcd_softc { 76 struct device dev; 77 /* control register */ 78 bus_space_tag_t iot; 79 bus_space_handle_t ioh; 80 bus_dma_tag_t dma_tag; 81 82 const struct lcd_panel_geometry *geometry; 83 84 int n_screens; 85 LIST_HEAD(, pxa2x0_lcd_screen) screens; 86 struct pxa2x0_lcd_screen *active; 87 void *ih; /* interrupt handler */ 88 }; 89 90 void pxa2x0_lcd_attach_sub( struct pxa2x0_softc *, 91 struct pxa2x0_lcd_softc *, const struct lcd_panel_geometry * ); 92 void pxa2x0_lcd_start_dma( struct pxa2x0_lcd_softc *, struct pxa2x0_lcd_screen * ); 93 94 struct lcd_panel_geometry { 95 short panel_width; 96 short panel_height; 97 short extra_lines; 98 99 short panel_info; 100 #define LCDPANEL_VSP (1<<0) /* L_FCLK pin is active low */ 101 #define LCDPANEL_HSP (1<<1) /* L_LCLK pin is active low */ 102 #define LCDPANEL_PCP (1<<2) /* use L_PCLK falling edge */ 103 #define LCDPANEL_OEP (1<<3) /* L_BIAS pin is active low */ 104 #define LCDPANEL_DPC (1<<4) /* double pixel clock mode */ 105 106 #define LCDPANEL_DUAL (1<<5) /* Dual or single */ 107 #define LCDPANEL_SINGLE 0 108 #define LCDPANEL_ACTIVE (1<<6) /* Active or Passive */ 109 #define LCDPANEL_PASSIVE 0 110 #define LCDPANEL_MONOCHROME (1<<7) /* depth=1 */ 111 112 short pixel_clock_div; /* pixel clock divider */ 113 short ac_bias; /* AC bias pin frequency */ 114 115 short hsync_pulse_width; /* Horizontao sync pulse width */ 116 short beg_line_wait; /* beginning of line wait (BLW) */ 117 short end_line_wait; /* end of line pxel wait (ELW) */ 118 119 short vsync_pulse_width; /* vertical sync pulse width */ 120 short beg_frame_wait; /* beginning of frame wait (BFW) */ 121 short end_frame_wait; /* end of frame wait (EFW) */ 122 }; 123 124 void pxa2x0_lcd_geometry( struct pxa2x0_lcd_softc *, 125 const struct lcd_panel_geometry *); 126 struct pxa2x0_lcd_screen *pxa2x0_lcd_new_screen( 127 struct pxa2x0_lcd_softc *, int depth ); 128 129 /* 130 * we need bits-per-pixel value to configure wsdisplay screen 131 */ 132 struct pxa2x0_wsscreen_descr { 133 struct wsscreen_descr c; /* standard descriptor */ 134 int depth; /* bits per pixel */ 135 }; 136 137 int pxa2x0_lcd_setup_wsscreen(struct pxa2x0_wsscreen_descr *, 138 const struct lcd_panel_geometry *, const char * ); 139 140 int pxa2x0_lcd_show_screen(void *, void *, int, void (*)(void *, int, int), void *); 141 int pxa2x0_lcd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p); 142 paddr_t pxa2x0_lcd_mmap(void *, off_t, int); 143 int pxa2x0_lcd_alloc_screen(void *, const struct wsscreen_descr *, 144 void **, int *, int *, long *); 145 void pxa2x0_lcd_free_screen(void *, void *); 146 147 extern const struct wsdisplay_emulops pxa2x0_lcd_emulops; 148 149 #endif /* _ARM_XSCALE_PXA2X0_LCD_H */ 150