pxa2x0_lcd.h revision 1.6 1 /* $NetBSD: pxa2x0_lcd.h,v 1.6 2006/12/17 16:03:33 peter 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 struct lcd_panel_geometry {
91 short panel_width;
92 short panel_height;
93 short extra_lines;
94
95 short panel_info;
96 #define LCDPANEL_VSP (1<<0) /* L_FCLK pin is active low */
97 #define LCDPANEL_HSP (1<<1) /* L_LCLK pin is active low */
98 #define LCDPANEL_PCP (1<<2) /* use L_PCLK falling edge */
99 #define LCDPANEL_OEP (1<<3) /* L_BIAS pin is active low */
100 #define LCDPANEL_DPC (1<<4) /* double pixel clock mode */
101
102 #define LCDPANEL_DUAL (1<<5) /* Dual or single */
103 #define LCDPANEL_SINGLE 0
104 #define LCDPANEL_ACTIVE (1<<6) /* Active or Passive */
105 #define LCDPANEL_PASSIVE 0
106 #define LCDPANEL_MONOCHROME (1<<7) /* depth=1 */
107
108 short pixel_clock_div; /* pixel clock divider */
109 short ac_bias; /* AC bias pin frequency */
110
111 short hsync_pulse_width; /* Horizontao sync pulse width */
112 short beg_line_wait; /* beginning of line wait (BLW) */
113 short end_line_wait; /* end of line pxel wait (ELW) */
114
115 short vsync_pulse_width; /* vertical sync pulse width */
116 short beg_frame_wait; /* beginning of frame wait (BFW) */
117 short end_frame_wait; /* end of frame wait (EFW) */
118 };
119
120 /*
121 * we need bits-per-pixel value to configure wsdisplay screen
122 */
123 struct pxa2x0_wsscreen_descr {
124 struct wsscreen_descr c; /* standard descriptor */
125 int depth; /* bits per pixel */
126 int flags; /* rasops flags */
127 };
128
129 void pxa2x0_lcd_attach_sub(struct pxa2x0_lcd_softc *,
130 struct pxaip_attach_args *, struct pxa2x0_wsscreen_descr *,
131 const struct lcd_panel_geometry *, int);
132 int pxa2x0_lcd_cnattach(struct pxa2x0_wsscreen_descr *,
133 const struct lcd_panel_geometry *);
134 void pxa2x0_lcd_start_dma(struct pxa2x0_lcd_softc *,
135 struct pxa2x0_lcd_screen *);
136
137 void pxa2x0_lcd_geometry(struct pxa2x0_lcd_softc *,
138 const struct lcd_panel_geometry *);
139 int pxa2x0_lcd_new_screen(struct pxa2x0_lcd_softc *, int,
140 struct pxa2x0_lcd_screen **);
141
142 int pxa2x0_lcd_setup_wsscreen(struct pxa2x0_wsscreen_descr *,
143 const struct lcd_panel_geometry *, const char * );
144
145 int pxa2x0_lcd_alloc_screen(void *, const struct wsscreen_descr *,
146 void **, int *, int *, long *);
147 void pxa2x0_lcd_free_screen(void *, void *);
148 int pxa2x0_lcd_ioctl(void *, void *, u_long, caddr_t, int, struct lwp *);
149 paddr_t pxa2x0_lcd_mmap(void *, void *, off_t, int);
150 int pxa2x0_lcd_show_screen(void *, void *, int, void (*)(void *, int, int),
151 void *);
152 void pxa2x0_lcd_power(int, void *);
153 void pxa2x0_lcd_suspend(struct pxa2x0_lcd_softc *);
154 void pxa2x0_lcd_resume(struct pxa2x0_lcd_softc *);
155
156 extern const struct wsdisplay_emulops pxa2x0_lcd_emulops;
157
158 #endif /* _ARM_XSCALE_PXA2X0_LCD_H */
159