ngle.h revision 7a5287f7
1a7fd8e5eSmacallan/* $OpenBSD: wsfb_driver.c,v 1.18 2003/04/02 16:42:13 jason Exp $ */
2a7fd8e5eSmacallan/*
3a7fd8e5eSmacallan * Copyright (c) 2024 Michael Lorenz
4a7fd8e5eSmacallan * All rights reserved.
5a7fd8e5eSmacallan *
6a7fd8e5eSmacallan * Redistribution and use in source and binary forms, with or without
7a7fd8e5eSmacallan * modification, are permitted provided that the following conditions
8a7fd8e5eSmacallan * are met:
9a7fd8e5eSmacallan *
10a7fd8e5eSmacallan *    - Redistributions of source code must retain the above copyright
11a7fd8e5eSmacallan *      notice, this list of conditions and the following disclaimer.
12a7fd8e5eSmacallan *    - Redistributions in binary form must reproduce the above
13a7fd8e5eSmacallan *      copyright notice, this list of conditions and the following
14a7fd8e5eSmacallan *      disclaimer in the documentation and/or other materials provided
15a7fd8e5eSmacallan *      with the distribution.
16a7fd8e5eSmacallan *
17a7fd8e5eSmacallan * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18a7fd8e5eSmacallan * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19a7fd8e5eSmacallan * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20a7fd8e5eSmacallan * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21a7fd8e5eSmacallan * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22a7fd8e5eSmacallan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23a7fd8e5eSmacallan * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24a7fd8e5eSmacallan * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25a7fd8e5eSmacallan * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26a7fd8e5eSmacallan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27a7fd8e5eSmacallan * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28a7fd8e5eSmacallan * POSSIBILITY OF SUCH DAMAGE.
29a7fd8e5eSmacallan *
30a7fd8e5eSmacallan */
31a7fd8e5eSmacallan
32a7fd8e5eSmacallan#include <fcntl.h>
33a7fd8e5eSmacallan#include <sys/types.h>
34a7fd8e5eSmacallan#include <sys/time.h>
35a7fd8e5eSmacallan#include <dev/wscons/wsconsio.h>
36a7fd8e5eSmacallan
37727c6de2Smacallan#include "xorg-server.h"
38a7fd8e5eSmacallan#include "xf86.h"
39a7fd8e5eSmacallan#include "xf86_OSproc.h"
40727c6de2Smacallan#include "compiler.h"
41727c6de2Smacallan#include "xorgVersion.h"
42a7fd8e5eSmacallan#include "xf86Cursor.h"
43727c6de2Smacallan#include "exa.h"
44a7fd8e5eSmacallan#include "compat-api.h"
45a7fd8e5eSmacallan
46a7fd8e5eSmacallan#ifndef NGLE_H
47a7fd8e5eSmacallan#define NGLE_H
48a7fd8e5eSmacallan
49a7fd8e5eSmacallan/* private data */
50a7fd8e5eSmacallantypedef struct {
51a7fd8e5eSmacallan	int			fd;
52a7fd8e5eSmacallan	struct wsdisplayio_fbinfo fbi;
53a7fd8e5eSmacallan	unsigned char*		fbmem;
54a7fd8e5eSmacallan	size_t			fbmem_len;
55a7fd8e5eSmacallan	void			*regs;
567517da51Smacallan	size_t			reglen;
57a7fd8e5eSmacallan	Bool			HWCursor;
58a7fd8e5eSmacallan	CloseScreenProcPtr	CloseScreen;
59a7fd8e5eSmacallan	CreateScreenResourcesProcPtr CreateScreenResources;
60a7fd8e5eSmacallan	EntityInfoPtr		pEnt;
61a7fd8e5eSmacallan	struct wsdisplay_cursor cursor;
62a7fd8e5eSmacallan	int			maskoffset;
63a7fd8e5eSmacallan	xf86CursorInfoPtr	CursorInfoRec;
64a7fd8e5eSmacallan	OptionInfoPtr		Options;
65727c6de2Smacallan	ExaDriverPtr		pExa;
667a5287f7Smacallan	uint32_t		gid, buf, fbacc, creg;
6797ec0daeSmacallan	int 			offset, hwmode, offsetd;
68727c6de2Smacallan#define HW_FB	0
69727c6de2Smacallan#define HW_FILL	1
70727c6de2Smacallan#define HW_BLIT	2
71da676487Smacallan#define HW_BINC	3
7297ec0daeSmacallan	uint32_t read_mode, write_mode;
73a7fd8e5eSmacallan} NGLERec, *NGLEPtr;
74a7fd8e5eSmacallan
75a7fd8e5eSmacallan#define NGLEPTR(p) ((NGLEPtr)((p)->driverPrivate))
76a7fd8e5eSmacallan
77a7fd8e5eSmacallanBool NGLESetupCursor(ScreenPtr);
78727c6de2SmacallanBool NGLEInitAccel(ScreenPtr);
797a5287f7SmacallanBool SummitSetupCursor(ScreenPtr);
807517da51SmacallanBool SummitInitAccel(ScreenPtr);
817517da51Smacallan
827517da51Smacallanstatic inline void
837517da51SmacallanNGLEWrite4(NGLEPtr fPtr, int offset, uint32_t val)
847517da51Smacallan{
857517da51Smacallan	volatile uint32_t *ptr = (uint32_t *)((uint8_t *)fPtr->regs + offset);
867517da51Smacallan	*ptr = val;
877517da51Smacallan}
887517da51Smacallan
897517da51Smacallanstatic inline void
907517da51SmacallanNGLEWrite1(NGLEPtr fPtr, int offset, uint8_t val)
917517da51Smacallan{
927517da51Smacallan	volatile uint8_t *ptr = (uint8_t *)fPtr->regs + offset;
937517da51Smacallan	*ptr = val;
947517da51Smacallan}
957517da51Smacallan
967517da51Smacallanstatic inline uint32_t
977517da51SmacallanNGLERead4(NGLEPtr fPtr, int offset)
987517da51Smacallan{
997517da51Smacallan	volatile uint32_t *ptr = (uint32_t *)((uint8_t *)fPtr->regs + offset);
1007517da51Smacallan	return *ptr;
1017517da51Smacallan}
1027517da51Smacallan
1037517da51Smacallanstatic inline uint8_t
1047517da51SmacallanNGLERead1(NGLEPtr fPtr, int offset)
1057517da51Smacallan{
1067517da51Smacallan	volatile uint8_t *ptr = (uint8_t *)fPtr->regs + offset;
1077517da51Smacallan	return *ptr;
1087517da51Smacallan}
109a7fd8e5eSmacallan
110a7fd8e5eSmacallan#endif
111