1 /* $NetBSD: imx51_ipuv3var.h,v 1.2 2014/05/06 11:22:53 hkenken 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 /* rasterop */ 56 struct rasops_info rinfo; 57 }; 58 59 struct lcd_panel_geometry { 60 short panel_width; 61 short panel_height; 62 63 uint32_t pixel_clk; 64 65 short hsync_width; 66 short left; 67 short right; 68 69 short vsync_width; 70 short upper; 71 short lower; 72 73 short panel_info; 74 #define IPUV3PANEL_SHARP (1<<0) /* sharp panel */ 75 uint32_t panel_sig_pol; 76 }; 77 78 struct imx51_ipuv3_softc { 79 device_t dev; 80 81 /* control register */ 82 bus_space_tag_t iot; 83 bus_space_handle_t cm_ioh; /* CM */ 84 bus_space_handle_t dmfc_ioh; /* DMFC */ 85 bus_space_handle_t di0_ioh; /* DI 0 */ 86 bus_space_handle_t dp_ioh; /* DP */ 87 bus_space_handle_t dc_ioh; /* DC */ 88 bus_space_handle_t idmac_ioh; /* IDMAC */ 89 bus_space_handle_t cpmem_ioh; /* CPMEM */ 90 bus_space_handle_t dctmpl_ioh; /* DCTMPL */ 91 bus_dma_tag_t dma_tag; 92 93 uint32_t flags; 94 #define FLAG_NOUSE_ACBIAS (1U<<0) 95 96 const struct lcd_panel_geometry *geometry; 97 98 int n_screens; 99 LIST_HEAD(, imx51_ipuv3_screen) screens; 100 struct imx51_ipuv3_screen *active; 101 void *ih; /* interrupt handler */ 102 103 /* virtual console support */ 104 struct vcons_data vd; 105 struct vcons_screen console; 106 int mode; 107 }; 108 109 /* 110 * we need bits-per-pixel value to configure wsdisplay screen 111 */ 112 struct imx51_wsscreen_descr { 113 struct wsscreen_descr c; /* standard descriptor */ 114 int depth; /* bits per pixel */ 115 int flags; /* rasops flags */ 116 }; 117 118 struct imx51_ipuv3_softc; 119 120 void imx51_ipuv3_attach_sub(struct imx51_ipuv3_softc *, 121 struct axi_attach_args *, const struct lcd_panel_geometry *); 122 int imx51_ipuv3_cnattach(bool, struct imx51_wsscreen_descr *, 123 struct wsdisplay_accessops *, 124 const struct lcd_panel_geometry *); 125 void imx51_ipuv3_start_dma(struct imx51_ipuv3_softc *, 126 struct imx51_ipuv3_screen *); 127 128 void imx51_ipuv3_geometry(struct imx51_ipuv3_softc *, 129 const struct lcd_panel_geometry *); 130 int imx51_ipuv3_new_screen(struct imx51_ipuv3_softc *, int, 131 struct imx51_ipuv3_screen **); 132 133 int imx51_ipuv3_alloc_screen(void *, const struct wsscreen_descr *, 134 void **, int *, int *, long *); 135 void imx51_ipuv3_free_screen(void *, void *); 136 int imx51_ipuv3_ioctl(void *, void *, u_long, void *, int, struct lwp *); 137 paddr_t imx51_ipuv3_mmap(void *, void *, off_t, int); 138 int imx51_ipuv3_show_screen(void *, void *, int, void (*)(void *, int, int), 139 void *); 140 141 extern const struct wsdisplay_emulops imx51_ipuv3_emulops; 142 143 #endif /* _ARM_IMX_IMX51_IPUV3_H */ 144