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