Home | History | Annotate | Line # | Download | only in s3c2xx0
      1 /* $NetBSD: s3c24x0_lcd.h,v 1.7 2022/05/23 21:46:11 andvar Exp $ */
      2 
      3 /*
      4  * Copyright (c) 2004  Genetec Corporation.  All rights reserved.
      5  * Written by Hiroyuki Bessho 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  * 3. The name of Genetec Corporation may not be used to endorse or
     16  *    promote products derived from this software without specific prior
     17  *    written permission.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
     20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 
     33 #ifndef _ARM_S3C2XX0_S3C24X0_LCD_H
     34 #define	_ARM_S3C2XX0_S3C24X0_LCD_H
     35 
     36 #include <dev/rasops/rasops.h>
     37 #include <sys/bus.h>
     38 
     39 /* LCD Contoroller */
     40 
     41 struct s3c24x0_lcd_screen {
     42 	LIST_ENTRY(s3c24x0_lcd_screen) link;
     43 
     44 	/* Frame buffer */
     45 	bus_dmamap_t dma;
     46 	bus_dma_segment_t segs[1];
     47 	int 	nsegs;
     48 	size_t  buf_size;
     49 	size_t  map_size;
     50 	void 	*buf_va;
     51 	int	depth;
     52 	int	stride;
     53 
     54 	/* rasterop */
     55 	struct rasops_info rinfo;
     56 };
     57 
     58 struct s3c24x0_lcd_softc {
     59 	device_t		sc_dev;
     60 
     61 	/* control registers */
     62 	bus_space_tag_t  	iot;
     63 	bus_space_handle_t	ioh;
     64 	bus_dma_tag_t    	dma_tag;
     65 
     66 	const struct s3c24x0_lcd_panel_info *panel_info;
     67 
     68 	LIST_HEAD(, s3c24x0_lcd_screen) screens;
     69 	struct s3c24x0_lcd_screen *active;
     70 	void *ih;			/* interrupt handler */
     71 
     72 	int n_screens;
     73 	int lcd_on;			/* LCD is turned on */
     74 };
     75 
     76 void s3c24x0_lcd_attach_sub(struct s3c24x0_lcd_softc *,
     77     struct s3c2xx0_attach_args *, const struct s3c24x0_lcd_panel_info *);
     78 int s3c24x0_lcd_start_dma(struct s3c24x0_lcd_softc *,
     79     struct s3c24x0_lcd_screen *);
     80 
     81 struct s3c24x0_lcd_panel_info {
     82 	short panel_width;
     83 	short panel_height;
     84 	int   pixel_clock;		/* in Hz */
     85 
     86 	/* Initial values to go to LCD control registers */
     87 	uint32_t lcdcon1;
     88 	uint32_t lcdcon2;
     89 	uint32_t lcdcon3;
     90 	uint32_t lcdcon4;
     91 	uint32_t lcdcon5;
     92 	uint32_t lpcsel;
     93 
     94 #define	s3c24x0_lcd_panel_tft(info)	\
     95 	(((info)->lcdcon1 & LCDCON1_PNRMODE_MASK) == LCDCON1_PNRMODE_TFT)
     96 };
     97 
     98 void s3c24x0_set_lcd_panel_info(struct s3c24x0_lcd_softc *,
     99     const struct s3c24x0_lcd_panel_info *);
    100 
    101 struct s3c24x0_lcd_screen *s3c24x0_lcd_new_screen(struct s3c24x0_lcd_softc *,
    102     int, int, int);
    103 
    104 /*
    105  * we need bits-per-pixel value to configure wsdisplay screen
    106  */
    107 struct s3c24x0_wsscreen_descr {
    108 	struct wsscreen_descr  c;	/* standard descriptor */
    109 	int depth;			/* bits per pixel */
    110 };
    111 
    112 int s3c24x0_lcd_show_screen(void *, void *, int, void (*)(void *, int, int),
    113     void *);
    114 int s3c24x0_lcd_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
    115     struct lwp *p);
    116 paddr_t	s3c24x0_lcd_mmap(void *, void *, off_t, int);
    117 int s3c24x0_lcd_alloc_screen(void *, const struct wsscreen_descr *, void **,
    118     int *, int *, long *);
    119 void s3c24x0_lcd_free_screen(void *, void *);
    120 void s3c24x0_lcd_power(struct s3c24x0_lcd_softc *, int);
    121 
    122 extern const struct wsdisplay_emulops s3c24x0_lcd_emulops;
    123 
    124 #endif /* _ARM_S3C2XX0_S3C24X0_LCD_H */
    125