imx51_ipuv3var.h revision 1.1 1 /* $NetBSD: imx51_ipuv3var.h,v 1.1 2012/04/17 10:19:57 bsh Exp $ */
2
3 /*
4 * Copyright (c) 2009, 2011, 2012 Genetec Corporation. All rights reserved.
5 * Written by Hashimoto Kenichi for Genetec Corporation.
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 *
16 * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29
30 #ifndef _ARM_IMX_IMX51_IPUV3_H
31 #define _ARM_IMX_IMX51_IPUV3_H
32
33 #include <sys/bus.h>
34 #include <dev/rasops/rasops.h>
35 #include <dev/wscons/wsdisplay_vconsvar.h>
36
37 /* IPUV3 Contoroller */
38 struct imx51_ipuv3_screen {
39 LIST_ENTRY(imx51_ipuv3_screen) link;
40
41 /* Frame buffer */
42 bus_dmamap_t dma;
43 bus_dma_segment_t segs[1];
44 int nsegs;
45 size_t buf_size;
46 size_t map_size;
47 void *buf_va;
48 int depth;
49 int stride;
50
51 /* DMA frame descriptor */
52 struct ipuv3_dma_descriptor *dma_desc;
53 paddr_t dma_desc_pa;
54 };
55
56 struct lcd_panel_geometry {
57 short panel_width;
58 short panel_height;
59
60 uint32_t pixel_clk;
61
62 short hsync_width;
63 short left;
64 short right;
65
66 short vsync_width;
67 short upper;
68 short lower;
69
70 short panel_info;
71 #define IPUV3PANEL_SHARP (1<<0) /* sharp panel */
72 uint32_t panel_sig_pol;
73 };
74
75 struct imx51_ipuv3_softc {
76 device_t dev;
77
78 /* control register */
79 bus_space_tag_t iot;
80 bus_space_handle_t cm_ioh; /* CM */
81 bus_space_handle_t dmfc_ioh; /* DMFC */
82 bus_space_handle_t di0_ioh; /* DI 0 */
83 bus_space_handle_t dp_ioh; /* DP */
84 bus_space_handle_t dc_ioh; /* DC */
85 bus_space_handle_t idmac_ioh; /* IDMAC */
86 bus_space_handle_t cpmem_ioh; /* CPMEM */
87 bus_space_handle_t dctmpl_ioh; /* DCTMPL */
88 bus_dma_tag_t dma_tag;
89
90 uint32_t flags;
91 #define FLAG_NOUSE_ACBIAS (1U<<0)
92
93 const struct lcd_panel_geometry *geometry;
94
95 int n_screens;
96 LIST_HEAD(, imx51_ipuv3_screen) screens;
97 struct imx51_ipuv3_screen *active;
98 void *ih; /* interrupt handler */
99
100 /* virtual console support */
101 struct vcons_data vd;
102 struct vcons_screen console;
103 int mode;
104 };
105
106 /*
107 * we need bits-per-pixel value to configure wsdisplay screen
108 */
109 struct imx51_wsscreen_descr {
110 struct wsscreen_descr c; /* standard descriptor */
111 int depth; /* bits per pixel */
112 int flags; /* rasops flags */
113 };
114
115 struct imx51_ipuv3_softc;
116
117 void imx51_ipuv3_attach_sub(struct imx51_ipuv3_softc *,
118 struct axi_attach_args *, const struct lcd_panel_geometry *);
119 int imx51_ipuv3_cnattach(const struct lcd_panel_geometry *);
120 void imx51_ipuv3_start_dma(struct imx51_ipuv3_softc *,
121 struct imx51_ipuv3_screen *);
122
123 void imx51_ipuv3_geometry(struct imx51_ipuv3_softc *,
124 const struct lcd_panel_geometry *);
125 int imx51_ipuv3_new_screen(struct imx51_ipuv3_softc *, int,
126 struct imx51_ipuv3_screen **);
127
128 int imx51_ipuv3_ioctl(void *, void *, u_long, void *, int, struct lwp *);
129 paddr_t imx51_ipuv3_mmap(void *, void *, off_t, int);
130
131 void imx51_ipuv3_power(int, void *);
132 void imx51_ipuv3_suspend(struct imx51_ipuv3_softc *);
133 void imx51_ipuv3_resume(struct imx51_ipuv3_softc *);
134
135 extern const struct wsdisplay_emulops imx51_ipuv3_emulops;
136
137 #endif /* _ARM_IMX_IMX51_IPUV3_H */
138