1
1
Fork 0

Драйвер devg-[vesabios/vpoutfb].so для ЗОСРВ "Нейтрино" редакции 2020

This commit is contained in:
commit 3d848c272c
57 changed files with 9486 additions and 0 deletions

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
LIST=DRIVERS
include recurse.mk

68
README.md Normal file
View File

@ -0,0 +1,68 @@
## Общая структура графического драйвера
```
┌───────────────────────────┐
│ │
│ Контроллер дисплеев │
│ │
└─────────────▴─────────────┘
┌─────────────┴─────────────┐
│ │
│ Графический драйвер │
│ (devg-*) │
│ │
└─────────────▴─────────────┘
*
┌─────────────┴─────────────┐ ┌───────────────────────────┐
│ │ │ │
│ Менеджер io-display ◂─── * ───┤ Клиентское приложение │
│ │ │ │
└───────────────────────────┘ ▲ └───────────────────────────┘
Интерфейс libgf ───────┘
```
## Дерево исходных кодов
```
|- devg/devnp/
| |- lib/ - Вспомогательные библиотеки
| |- private/ - Приватные хедеры графической подсистемы
| |- public/ - Публичные хедеры графической подсистемы
| |- vesabios/ - Исходный код универсального драйвера контроллера дисплеев (группа стандартов VESA)
| |- vpoutfb/ - Исходный код драйвера контроллера дисплеев для Элвис 1892ВМ14Я (ARMv7 SoC)
| |- common.mk - Параметры сборки драйверов
| `- Makefile - Правила сборки дерева исходников
|
`- Makefile - Правила сборки дерева исходников
```
## Сборка драйвера
- Установить и настроить [комплект разработчика](https://help.kpda.ru/help/topic/ru.kpda.doc.dev_tools_ru/html/devkit/devkit.html) для [ЗОСРВ "Нейтрино" редакции 2020](https://help.kpda.ru/help/index.jsp).
- Выполнить команду:
```
make
```
## Запуск драйвера
Общая схема запуска драйвера:
```
io-display -dvid=0x0,did=0x0
```
Особенности запуска и настройки графических драйверов представлены в статье [Настройка графической подсистемы](https://help.kpda.ru/help/topic/ru.kpda.doc.graphics_ru/html/user_guide/guide/configuration.html).

3
devg/Makefile Normal file
View File

@ -0,0 +1,3 @@
EARLY_DIRS=lib
LIST=DEVG
include recurse.mk

107
devg/common.mk Normal file
View File

@ -0,0 +1,107 @@
#
# (c) 2010, SWD Embedded Systems Limited, http://www.kpda.ru
#
ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)
define PINFO
PINFO DESCRIPTION=
endef
EXTRA_SILENT_VARIANTS = $(subst -, ,$(SECTION))
ifeq ($(NAME),)
NAME=$(PROJECT)-$(SECTION)
endif
CCVFLAG_fixed=-DDISP_FIXED_POINT
DEVGDRVROOT=$(shell $(PWD_HOST) | sed 's!\/devg.*!\/devg!')/$(shell $(PWD_HOST) | sed 's!.*\/devg[^\/]*\/!!' | sed 's!\/.*!!')
include $(MKFILES_ROOT)/qmacros.mk
-include $(PROJECT_ROOT)/roots.mk
#
# Set this as the default, each devg's pinfo.mk can override if needed.
#
SHARED_LIBS=ffb disputilS
include $(PROJECT_ROOT)/$(SECTION)/pinfo.mk
USEFILE := ../../../$(SECTION).use
CONFIG_PATH := $(PROJECT_ROOT)/$(SECTION)/config
#EXTRA_INCVPATH += $(if $(USE_INSTALL_ROOT),$(INSTALL_ROOT_$(OS)),$(USE_ROOT_$(OS)))/usr/include/graphics
EXTRA_INCVPATH += $(PROJECT_ROOT)/public/graphics
EXTRA_INCVPATH += $(PROJECT_ROOT)/public
EXTRA_INCVPATH += $(PROJECT_ROOT)/private
EXTRA_INCVPATH += $(PROJECT_ROOT)/private/drm
EXTRA_INCVPATH += $(PROJECT_ROOT)/private/linux
EXTRA_INCVPATH += $(PROJECT_ROOT)/private/linux/include
EXTRA_INCVPATH += $(PROJECT_ROOT)/private/linux/include/uapi
EXTRA_INCVPATH += $(PROJECT_ROOT)/private/linux/arch/$(CPU)
EXTRA_INCVPATH += $(PROJECT_ROOT)/private/linux/arch/$(CPU)/include
EXTRA_INCVPATH += $(PROJECT_ROOT)/private/linux/arch/$(CPU)/include/uapi
ifneq ($(OS), qnx4)
ifneq ($(COMPOUND_VARIANT),dll)
ifneq ($(COMPOUND_VARIANT),dll.g)
SHARED_LIBDIR = $(OS)/$(CPU)/so.$(patsubst dll.%,%,$(COMPOUND_VARIANT))
STATIC_LIBDIR = $(OS)/$(CPU)/a.shared.$(patsubst dll.%,%,$(COMPOUND_VARIANT))
else
SHARED_LIBDIR = $(OS)/$(CPU)/so.g
STATIC_LIBDIR = $(OS)/$(CPU)/a.shared.g
endif
else
SHARED_LIBDIR = $(OS)/$(CPU)/so
STATIC_LIBDIR = $(OS)/$(CPU)/a.shared
endif
-include $(DEVGDRVROOT)/extrasrc.mk
-include $(DEVGDRVROOT)/driver.mk
include $(MKFILES_ROOT)/qtargets.mk
ifeq ($(origin NDEBUG),undefined)
CCFLAGS += -O0
else
CCFLAGS += -fomit-frame-pointer
endif
CCFLAGS += -Wno-switch
else # qnx4
ifneq ($(COMPOUND_VARIANT), a.g)
SHARED_LIBDIR = $(OS)/$(CPU)/a
STATIC_LIBDIR = $(OS)/$(CPU)/a
SHARED_LIBS += iographics photon3r $(QNX4_LIBS)
else
SHARED_LIBDIR = $(OS)/$(CPU)/a.g
STATIC_LIBDIR = $(OS)/$(CPU)/a.g
SHARED_LIBS += iographics photon3r $(QNX4_LIBS)
endif
SHARED_LIBS += $(QNX4_LIBS)
LDFLAGS += -T1
CCFLAGS += -Otax -D__X86__ -D__LITTLEENDIAN__
endif
ifeq ($(origin NDEBUG),undefined)
ifeq ($(OS), qnx4)
LIBS += $(foreach lib, $(STATIC_LIBS), $(lib)S) $(SHARED_LIBS)
else
LIBS += $(foreach lib, $(STATIC_LIBS), $(lib)S_g) $(foreach lib, $(SHARED_LIBS), $(lib)_g)
endif
else
LIBS += $(foreach lib, $(STATIC_LIBS), $(lib)S) $(SHARED_LIBS)
endif
WIN32_ENVIRON=mingw
ifeq "$(findstring e2k,$(CPU))" "e2k"
CCFLAGS += -D__DEF_BELOW4G_TMEM__=\"/below4G/ram\"
CCFLAGS += -fcontrol-spec
endif

251
devg/private/drm/drm_edid.h Normal file
View File

@ -0,0 +1,251 @@
/*
* Copyright © 2007-2008 Intel Corporation
* Jesse Barnes <jesse.barnes@intel.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __DRM_EDID_H__
#define __DRM_EDID_H__
#ifdef __QNX__
#ifdef __QNXNTO__
/* Pack all structures */
#include <_pack1.h>
#else
#pragma pack (1)
#endif
#endif
#define EDID_LENGTH 128
#define DDC_ADDR 0x50
#define DDC_ADDR2 0x52 /* E-DDC 1.2 - where DisplayID can hide */
#define CEA_EXT 0x02
#define VTB_EXT 0x10
#define DI_EXT 0x40
#define LS_EXT 0x50
#define MI_EXT 0x60
#define DISPLAYID_EXT 0x70
struct est_timings {
uint8_t t1;
uint8_t t2;
uint8_t mfg_rsvd;
};
/* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
#define EDID_TIMING_ASPECT_SHIFT 6
#define EDID_TIMING_ASPECT_MASK (0x3 << EDID_TIMING_ASPECT_SHIFT)
/* need to add 60 */
#define EDID_TIMING_VFREQ_SHIFT 0
#define EDID_TIMING_VFREQ_MASK (0x3f << EDID_TIMING_VFREQ_SHIFT)
struct std_timing {
uint8_t hsize; /* need to multiply by 8 then add 248 */
uint8_t vfreq_aspect;
};
#define DRM_EDID_PT_HSYNC_POSITIVE (1 << 1)
#define DRM_EDID_PT_VSYNC_POSITIVE (1 << 2)
#define DRM_EDID_PT_SEPARATE_SYNC (3 << 3)
#define DRM_EDID_PT_STEREO (1 << 5)
#define DRM_EDID_PT_INTERLACED (1 << 7)
/* If detailed data is pixel timing */
struct detailed_pixel_timing {
uint8_t hactive_lo;
uint8_t hblank_lo;
uint8_t hactive_hblank_hi;
uint8_t vactive_lo;
uint8_t vblank_lo;
uint8_t vactive_vblank_hi;
uint8_t hsync_offset_lo;
uint8_t hsync_pulse_width_lo;
uint8_t vsync_offset_pulse_width_lo;
uint8_t hsync_vsync_offset_pulse_width_hi;
uint8_t width_mm_lo;
uint8_t height_mm_lo;
uint8_t width_height_mm_hi;
uint8_t hborder;
uint8_t vborder;
uint8_t misc;
};
/* If it's not pixel timing, it'll be one of the below */
struct detailed_data_string {
uint8_t str[13];
};
struct detailed_data_monitor_range {
uint8_t min_vfreq;
uint8_t max_vfreq;
uint8_t min_hfreq_khz;
uint8_t max_hfreq_khz;
uint8_t pixel_clock_mhz; /* need to multiply by 10 */
uint8_t flags;
union {
struct {
uint8_t reserved;
uint8_t hfreq_start_khz; /* need to multiply by 2 */
uint8_t c; /* need to divide by 2 */
uint16_t m;
uint8_t k;
uint8_t j; /* need to divide by 2 */
} gtf2;
struct {
uint8_t version;
uint8_t data1; /* high 6 bits: extra clock resolution */
uint8_t data2; /* plus low 2 of above: max hactive */
uint8_t supported_aspects;
uint8_t flags; /* preferred aspect and blanking support */
uint8_t supported_scalings;
uint8_t preferred_refresh;
} cvt;
} formula;
};
struct detailed_data_wpindex {
uint8_t white_yx_lo; /* Lower 2 bits each */
uint8_t white_x_hi;
uint8_t white_y_hi;
uint8_t gamma; /* need to divide by 100 then add 1 */
};
struct detailed_data_color_point {
uint8_t windex1;
uint8_t wpindex1[3];
uint8_t windex2;
uint8_t wpindex2[3];
};
struct cvt_timing {
uint8_t code[3];
};
struct detailed_non_pixel {
uint8_t pad1;
uint8_t type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
fb=color point data, fa=standard timing data,
f9=undefined, f8=mfg. reserved */
uint8_t pad2;
union {
struct detailed_data_string str;
struct detailed_data_monitor_range range;
struct detailed_data_wpindex color;
struct std_timing timings[6];
struct cvt_timing cvt[4];
} data;
};
#define EDID_DETAIL_EST_TIMINGS 0xf7
#define EDID_DETAIL_CVT_3BYTE 0xf8
#define EDID_DETAIL_COLOR_MGMT_DATA 0xf9
#define EDID_DETAIL_STD_MODES 0xfa
#define EDID_DETAIL_MONITOR_CPDATA 0xfb
#define EDID_DETAIL_MONITOR_NAME 0xfc
#define EDID_DETAIL_MONITOR_RANGE 0xfd
#define EDID_DETAIL_MONITOR_STRING 0xfe
#define EDID_DETAIL_MONITOR_SERIAL 0xff
struct detailed_timing {
uint16_t pixel_clock; /* need to multiply by 10 KHz */
union {
struct detailed_pixel_timing pixel_data;
struct detailed_non_pixel other_data;
} data;
};
#define DRM_EDID_INPUT_SERRATION_VSYNC (1 << 0)
#define DRM_EDID_INPUT_SYNC_ON_GREEN (1 << 1)
#define DRM_EDID_INPUT_COMPOSITE_SYNC (1 << 2)
#define DRM_EDID_INPUT_SEPARATE_SYNCS (1 << 3)
#define DRM_EDID_INPUT_BLANK_TO_BLACK (1 << 4)
#define DRM_EDID_INPUT_VIDEO_LEVEL (3 << 5)
#define DRM_EDID_INPUT_DIGITAL (1 << 7)
struct edid {
uint8_t header[8];
/* Vendor & product info */
uint8_t mfg_id[2];
uint8_t prod_code[2];
uint32_t serial; /* FIXME: byte order */
uint8_t mfg_week;
uint8_t mfg_year;
/* EDID version */
uint8_t version;
uint8_t revision;
/* Display info: */
uint8_t input;
uint8_t width_cm;
uint8_t height_cm;
uint8_t gamma;
uint8_t features;
/* Color characteristics */
uint8_t red_green_lo;
uint8_t black_white_lo;
uint8_t red_x;
uint8_t red_y;
uint8_t green_x;
uint8_t green_y;
uint8_t blue_x;
uint8_t blue_y;
uint8_t white_x;
uint8_t white_y;
/* Est. timings and mfg rsvd timings*/
struct est_timings established_timings;
/* Standard timings 1-8*/
struct std_timing standard_timings[8];
/* Detailing timings 1-4 */
struct detailed_timing detailed_timings[4];
/* Number of 128 byte ext. blocks */
uint8_t extensions;
/* Checksum */
uint8_t checksum;
};
struct drm_encoder;
struct drm_connector;
struct drm_display_mode;
struct hdmi_avi_infoframe;
struct hdmi_vendor_infoframe;
struct i2c_adapter;
struct edid *drm_get_edid(struct drm_connector *connector,
struct i2c_adapter *adapter);
struct edid *drm_get_edid_size( struct drm_connector *connector, struct i2c_adapter *adapter, int size );
struct edid *drm_edid_duplicate(const struct edid *edid);
uint8_t drm_match_cea_mode(const struct drm_display_mode *to_match);
enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const uint8_t video_code);
bool drm_detect_hdmi_monitor(struct edid *edid);
int drm_hdmi_avi_infoframe_from_display_mode( struct hdmi_avi_infoframe *frame, const struct drm_display_mode *mode);
int drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame, const struct drm_display_mode *mode);
bool drm_edid_is_valid(struct edid *edid);
#ifdef __QNX__
#ifdef __QNXNTO__
#include <_packpop.h>
#else
#pragma pack ()
#endif
#endif
#endif /* __DRM_EDID_H__ */

758
devg/public/graphics/3d.h Normal file
View File

@ -0,0 +1,758 @@
/*
* (c) 2020, SWD Embedded Systems Limited, http://www.kpda.ru
*/
/* KPDA has no driver-dependent GLES headers */
#if 0
#ifndef _GRAPHICS_3D_H_INCLUDED
#define _GRAPHICS_3D_H_INCLUDED
#ifndef _GRAPHICS_DISPLAY_H_INCLUDED
#include <graphics/display.h>
#endif
#ifndef _GLES_GL_H_INCLUDED
#include <GLES/gl.h>
#endif
#ifndef _GLES_GLEXT_H_INCLUDED
#include <GLES/glext.h>
#endif
#ifndef _GRAPHICS_REND_H_INCLUDED
#include <graphics/rend.h>
#endif
/* Sizes of the matrix stacks */
#define DISP_3D_MODEL_MATRIX_ENTRIES 16
#define DISP_3D_PROJ_MATRIX_ENTRIES 2
#define DISP_3D_TEX_MATRIX_ENTRIES 2
/* Max supported lights */
#define DISP_3D_NUM_LIGHTS 8
/* Max supported texture mapping units */
#define DISP_3D_MAX_TMUS 4
/* Max supported texture dimensions */
#define DISP_3D_MAX_TEXTURE_SIZE 2048
#define DISP_3D_LOG2_MAX_TEXTURE_SIZE 11
#define __MKFMT(__bpp, __id) ((__id) | (__bpp)<<24)
#define DISP_TEX_BITS_PER_PIXEL(__fmt) ((__fmt)>>24)
#define DISP_TEXFORMAT_UNDEFINED 0
#define DISP_TEXFORMAT_RGBA8888 __MKFMT(32, 1)
#define DISP_TEXFORMAT_RGB888 __MKFMT(24, 2)
#define DISP_TEXFORMAT_PK_RGBA4444 __MKFMT(16, 3)
#define DISP_TEXFORMAT_PK_ARGB4444 __MKFMT(16, 4)
#define DISP_TEXFORMAT_PK_RGBA5551 __MKFMT(16, 5)
#define DISP_TEXFORMAT_PK_RGB565 __MKFMT(16, 6)
#define DISP_TEXFORMAT_PKOE_RGBA4444 __MKFMT(16, 7)
#define DISP_TEXFORMAT_PKOE_ARGB4444 __MKFMT(16, 8)
#define DISP_TEXFORMAT_PKOE_RGB565 __MKFMT(16, 9)
#define DISP_TEXFORMAT_LA88 __MKFMT(16, 10)
#define DISP_TEXFORMAT_L8 __MKFMT(8, 11)
#define DISP_TEXFORMAT_A8 __MKFMT(8, 12)
#define DISP_TEXFORMAT_PAL8_RGB888 __MKFMT(8, 13)
#define DISP_TEXFORMAT_PAL8_RGBA8888 __MKFMT(8, 14)
#define DISP_TEXFORMAT_PAL4_RGB888 __MKFMT(4, 15)
#define DISP_TEXFORMAT_PAL4_RGBA8888 __MKFMT(4, 16)
#define DISP_TEXFORMAT_ARGB8888 __MKFMT(32, 17)
#define DISP_TEXFORMAT_PK_ARGB1555 __MKFMT(16, 18)
#define DISP_TEXFORMAT_PK_XRGB1555 __MKFMT(16, 19)
#define DISP_TEXFORMAT_PKOE_ARGB1555 __MKFMT(16, 20)
#define DISP_TEXFORMAT_PKOE_XRGB1555 __MKFMT(16, 21)
#define DISP_TEXFORMAT_BGR888 __MKFMT(24, 22)
#define DISP_TEXFORMAT_BGRA8888 __MKFMT(32, 23)
#define DISP_TEXFORMAT_PKOE_RGBA5551 __MKFMT(16, 24)
#define DISP_TEXFORMAT_ABGR8888 __MKFMT(32, 25)
#define DISP_TEXFORMAT_AL88 __MKFMT(16, 26)
/* Fujitsu proprietary compression */
#define DISP_TEXFORMAT_FJCMP_RGBA5551 __MKFMT(16, 27)
#define DISP_TEXFORMAT_FJCMP_RGBA8888 __MKFMT(32, 28)
/* PRVTC compression */
#define DISP_TEXFORMAT_PVRTC_RGB_4BPPV1 __MKFMT(4, 29)
#define DISP_TEXFORMAT_PVRTC_RGB_2BPPV1 __MKFMT(2, 30)
#define DISP_TEXFORMAT_PVRTC_RGBA_4BPPV1 __MKFMT(4, 31)
#define DISP_TEXFORMAT_PVRTC_RGBA_2BPPV1 __MKFMT(2, 32)
/* Only valid when indicating a preferred internal texture format */
#define DISP_TEXFORMAT_RGB_ANY 100
#define DISP_TEXFORMAT_RGBA_ANY 101
#define DISP_3D_STATE_MODELMATRIX 0x00000001
#define DISP_3D_STATE_PROJMATRIX 0x00000002
#define DISP_3D_STATE_TEXMATRIX 0x00000004
#define DISP_3D_STATE_NORMAL 0x00000008
#define DISP_3D_STATE_DEPTH_RANGE 0x00000010
#define DISP_3D_STATE_SHADING 0x00000020
#define DISP_3D_STATE_DEPTH 0x00000040
#define DISP_3D_STATE_ALPHA_TEST 0x00000080
#define DISP_3D_STATE_BLEND 0x00000100
#define DISP_3D_STATE_STENCIL 0x00000200
#define DISP_3D_STATE_LOGIC_OP 0x00000400
#define DISP_3D_STATE_FOG 0x00000800
#define DISP_3D_STATE_TMU 0x00001000
#define DISP_3D_STATE_COLORMASK 0x00002000
#define DISP_3D_STATE_POLYGON_OFFSET 0x00004000
#define DISP_3D_STATE_VIEWPORT 0x00008000
#define DISP_3D_STATE_CULLFACE 0x00010000
#define DISP_3D_STATE_SCISSOR 0x00020000
#define DISP_3D_STATE_LIGHT 0x00040000
#define DISP_3D_STATE_FLAGS 0x00080000
#define DISP_3D_STATE_ANTIALIAS 0x00100000
#define DISP_3D_STATE_POINT 0x00200000
#define DISP_3D_STATE_LINE 0x00400000
#define DISP_3D_STATE_FSOPS 0x00800000
/* Global light state */
#define DISP_3D_LIGHT_STATE_TWO_SIDE 0x00000001
#define DISP_3D_LIGHT_STATE_AMBIENT 0x00000002
#define DISP_3D_LIGHT_STATE_MAT_AMBIENT 0x00000004
#define DISP_3D_LIGHT_STATE_MAT_DIFFUSE 0x00000008
#define DISP_3D_LIGHT_STATE_MAT_SPECULAR 0x00000010
#define DISP_3D_LIGHT_STATE_MAT_EMISSION 0x00000020
#define DISP_3D_LIGHT_STATE_MAT_SHININESS 0x00000040
#define DISP_3D_LIGHT_STATE_COLOR_MATERIAL 0x00000080
/* Per-light state */
#define DISP_3D_PER_LIGHT_STATE_AMBIENT 0x00000001
#define DISP_3D_PER_LIGHT_STATE_DIFFUSE 0x00000002
#define DISP_3D_PER_LIGHT_STATE_SPECULAR 0x00000004
#define DISP_3D_PER_LIGHT_STATE_POSITION 0x00000008
#define DISP_3D_PER_LIGHT_STATE_SPOT_DIRECTION 0x00000010
#define DISP_3D_PER_LIGHT_STATE_SPOT_EXPONENT 0x00000020
#define DISP_3D_PER_LIGHT_STATE_SPOT_CUTOFF 0x00000040
#define DISP_3D_PER_LIGHT_STATE_CONSTANT_ATTENUATION 0x00000080
#define DISP_3D_PER_LIGHT_STATE_LINEAR_ATTENUATION 0x00000100
#define DISP_3D_PER_LIGHT_STATE_QUADRATIC_ATTENUATION 0x00000200
/* Buffer objects */
#define DISP_3D_BUFOBJ_NONE 0x00000000
#define DISP_3D_BUFOBJ_VERTEX 0x00000001
#define DISP_3D_BUFOBJ_COLOR 0x00000002
#define DISP_3D_BUFOBJ_NORMAL 0x00000004
#define DISP_3D_BUFOBJ_TEXCOORD0 0x00000008
#define DISP_3D_BUFOBJ_TEXCOORD1 0x00000010
#define DISP_3D_BUFOBJ_TEXCOORD2 0x00000020
#define DISP_3D_BUFOBJ_TEXCOORD3 0x00000040
#define DISP_3D_BUFOBJ_INDICES 0x00010000
/* Datatypes for data in buffer objects */
#define DISP_3D_DATATYPE_NONE 0x00000000
#define DISP_3D_DATATYPE_CHAR 0x00000001
#define DISP_3D_DATATYPE_UCHAR 0x00000002
#define DISP_3D_DATATYPE_SHORT 0x00000003
#define DISP_3D_DATATYPE_USHORT 0x00000004
#define DISP_3D_DATATYPE_FIXED32 0x00000005
#define DISP_3D_DATATYPE_FLOAT32 0x00000006
/* For specifying how primitive information will be sent to driver */
typedef enum {
DISP_3D_SEND_OBJECT_COORDS = 0x00000001, /* Send vertices in Object/World coordinates */
DISP_3D_SEND_LIT_EYE_COORDS = 0x00000002, /* Send vertices in Eye coordinates, after lighting */
DISP_3D_SEND_CLIPPED_PRIMS = 0x00000004, /* Send clipped primitives */
DISP_3D_SEND_SPANS = 0x00000010, /* Render primitives as a series of spans */
} disp_3d_send_type;
/* Actions to be taken on vertices before sending to driver */
typedef enum {
DISP_3D_PRIMSTATE_XFORM_TEX = 0x00000001, /* Multiply texture coordinates by current texture matrix */
DISP_3D_PRIMSTATE_DIV_BY_W = 0x00000002, /* Perform division by W (clipped primitives only) */
DISP_3D_PRIMSTATE_VP_XLATE = 0x00000004, /* Translate to viewport coordinates (clipped primitives only) */
} disp_3d_primstate_flag;
typedef enum {
DISP_3D_DATA_COORDS, /* X, Y, Z, W */
DISP_3D_DATA_NORMAL, /* X, Y, Z */
DISP_3D_DATA_RGBA, /* R, G, B, A */
DISP_3D_DATA_STRQ0, /* S, T, R, Q */
DISP_3D_DATA_STRQ1, /* S, T, R, Q */
DISP_3D_DATA_STRQ2, /* S, T, R, Q */
DISP_3D_DATA_STRQ3, /* S, T, R, Q */
DISP_3D_DATA_FOG, /* Fog distance */
} disp_3d_data_type;
typedef enum {
DISP_3D_CTX_FLAG_USE_VTXCOLOR = 0x00000001,
DISP_3D_CTX_FLAG_USE_VTXNORM = 0x00000002,
DISP_3D_CTX_FLAG_PRIM_USE_VTXCOLOR = 0x00000004
} disp_3d_ctx_flag;
/* Driver may set these flags when processing Lit Eye Co-ordinates, if it
* determines that it can't process the specified primitives correctly.
* For example, the driver may be able to render triangle strips and
* fans etc., but cannot handle the case where vertices are outside of the
* far or near clipping planes.
*/
typedef enum {
DISP_3D_PCTL_FLAG_LEC_FBACK_MM_CP = 0x00000001, /* Matrix multiplication still needs to be performed on the vertices, and the driver is prepared to accept clipped primitives */
DISP_3D_PCTL_FLAG_LEC_FBACK_CP = 0x00000002, /* The driver is prepared to accept clipped primitives */
DISP_3D_PCTL_FLAG_LEC_FBACK_MM_SPANS = 0x00000004, /* Matrix multiplication still needs to be performed on the vertices, and the driver can only accept spans */
DISP_3D_PCTL_FLAG_LEC_FBACK_SPANS = 0x00000008, /* The driver can only accept spans */
} disp_3d_pctl_flag;
#define DISP_3D_PCTL_FLAG_LEC_FBACK_MASK \
(DISP_3D_PCTL_FLAG_LEC_FBACK_MM_CP | \
DISP_3D_PCTL_FLAG_LEC_FBACK_CP | \
DISP_3D_PCTL_FLAG_LEC_FBACK_MM_SPANS | \
DISP_3D_PCTL_FLAG_LEC_FBACK_SPANS)
typedef enum {
DISP_3D_MATRIX_FLAG_IS_IDENTITY = 0x00000001,
} disp_3d_matrix_flag;
/* Defines for "flags" argument to prim_begin() */
#define DISP_3D_VTX_FLAG_DFLT_Z 0x00000001
#define DISP_3D_VTX_FLAG_DFLT_W 0x00000002
#define DISP_3D_VTX_FLAG_DFLT_R(__tmu) (1<<((__tmu)+4))
#define DISP_3D_VTX_FLAG_DFLT_Q(__tmu) (1<<((__tmu)+12))
typedef struct {
int allocated;
unsigned format[DISP_3D_LOG2_MAX_TEXTURE_SIZE+1]; /* See DISP_3D_TEXFORMAT_* */
int max_lod;
GLfixed switchover;
void *image[DISP_3D_LOG2_MAX_TEXTURE_SIZE+1];
int width[DISP_3D_LOG2_MAX_TEXTURE_SIZE+1];
int height[DISP_3D_LOG2_MAX_TEXTURE_SIZE+1];
int stride[DISP_3D_LOG2_MAX_TEXTURE_SIZE+1];
void *palette;
int compressed_size;
GLenum min_filter;
GLenum mag_filter;
int min_linear;
GLenum wrap_s;
GLenum wrap_t;
void *driver_private;
} disp_texture_t;
typedef struct {
unsigned name;
GLenum usage;
unsigned size; /* In bytes */
void *dataptr;
void *driver_private;
} disp_bufobj_t;
typedef struct light_state {
struct {
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} ambient;
struct {
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} diffuse;
struct {
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} specular;
struct {
disp_real x;
disp_real y;
disp_real z;
disp_real w;
} position;
struct {
disp_real x;
disp_real y;
disp_real z;
GLboolean transformed;
} spot_direction;
disp_real spot_exponent;
disp_real spot_cutoff;
disp_real cos_spot_cutoff;
disp_real constant_attenuation;
disp_real linear_attenuation;
disp_real quadratic_attenuation;
GLboolean enabled;
unsigned new_state;
unsigned imp_flags;
unsigned reserved[3];
} disp_3d_light_state_t;
typedef struct {
int enabled;
int complete;
disp_real s;
disp_real t;
disp_real r;
disp_real q;
GLenum env_mode;
int function;
disp_real env_r;
disp_real env_g;
disp_real env_b;
disp_real env_a;
disp_real tex_matrix[DISP_3D_TEX_MATRIX_ENTRIES][16];
disp_3d_matrix_flag tex_matrix_flags[DISP_3D_TEX_MATRIX_ENTRIES];
int tex_matrix_stackptr;
} disp_tmu_state_t;
typedef struct {
disp_real x;
disp_real y;
disp_real z;
disp_real w;
disp_real r[2];
disp_real g[2];
disp_real b[2];
disp_real a;
disp_real fog;
struct {
disp_real s;
disp_real t;
disp_real r;
disp_real q;
} t[DISP_3D_MAX_TMUS];
union {
struct {
disp_real x;
disp_real y;
disp_real z;
} normal;
struct {
/*
* Stores NDC's or Viewports coords, depending
* on what the device wants.
*/
disp_real x;
disp_real y;
disp_real z;
} ndc;
} u;
unsigned flags; /* Not for driver's use */
} disp_3d_vertex_t;
typedef struct disp_3d_span_params {
struct disp_rendercontext *rctx;
GLfixed r_start;
GLfixed r_step;
GLfixed g_start;
GLfixed g_step;
GLfixed b_start;
GLfixed b_step;
GLfixed a_start;
GLfixed a_step;
GLfixed f_start;
GLfixed f_step;
int z_start;
int z_step;
GLfixed *spanbuf;
GLfixed *cvgbuf;
unsigned reserved[7];
} disp_3d_span_params_t;
typedef struct disp_3d_prim_state {
disp_3d_send_type send_type;
disp_3d_primstate_flag flags;
unsigned reserved[4];
} disp_3d_prim_state_t;
typedef struct disp_3d_data_ptr {
disp_real *xptr;
disp_real *yptr;
disp_real *zptr;
disp_real *wptr;
disp_real *rptr;
disp_real *gptr;
disp_real *bptr;
disp_real *aptr;
disp_real *tsptr[DISP_3D_MAX_TMUS];
disp_real *ttptr[DISP_3D_MAX_TMUS];
disp_real *trptr[DISP_3D_MAX_TMUS];
disp_real *tqptr[DISP_3D_MAX_TMUS];
int xstride;
int ystride;
int zstride;
int wstride;
int rstride;
int gstride;
int bstride;
int astride;
int tsstride[DISP_3D_MAX_TMUS];
int ttstride[DISP_3D_MAX_TMUS];
int trstride[DISP_3D_MAX_TMUS];
int tqstride[DISP_3D_MAX_TMUS];
disp_real *nxptr;
disp_real *nyptr;
disp_real *nzptr;
int nxstride;
int nystride;
int nzstride;
uint32_t reserved[6];
} disp_3d_data_ptrs_t;
__BEGIN_DECLS
typedef struct disp_3d_pipeline_ctl {
disp_3d_prim_state_t tri;
disp_3d_prim_state_t line;
disp_3d_prim_state_t points;
void (*prim_begin)(void *context,
GLenum primitive, int nvertices, unsigned flags);
void (*prim_end)(void *context);
/* For drivers that can do lighting and/or view volume clipping */
void (*send_vertices)(void *context, int nvertices);
/* For drivers that can do view volume clipping, but not lighting */
void (*send_lit_vertices)(void *context,
disp_3d_vertex_t *v, int nvertices);
/* For drivers that take pre-lit, pre-clipped primitives */
void (*draw_triangle)(void *context,
disp_3d_vertex_t *v1, disp_3d_vertex_t *v2, disp_3d_vertex_t *v3);
void (*draw_line)(void *context,
disp_3d_vertex_t *v1, disp_3d_vertex_t *v2);
void (*draw_points)(void *context, disp_3d_vertex_t *v, int npoints);
/* Span function supporting OpenGL ES per-fragment operations */
void (*draw_span)(void *context,
int x, int y, int count, disp_3d_span_params_t *params);
disp_3d_data_ptrs_t *data_ptrs;
int max_vertices;
/* For drivers with direct access to array data via buffer objects */
int (*draw_arrays)(void *context, GLenum prim, int first, int nvertices);
int (*draw_elements)(void *context, GLenum,
unsigned nvertices, disp_bufobj_t *obj, unsigned datatype);
int (*draw_elements_immed)(void *context, GLenum,
unsigned nvertices, const void *data, unsigned datatype);
/* See DISP_3D_PCTL_FLAG_* */
uint32_t flags;
uint32_t reserved[3];
} disp_3d_pipeline_ctl_t;
typedef struct disp_rendercontext {
unsigned new_state; /* See DISP_3D_STATE_* */
unsigned new_global_light_state; /* See DISP_3D_LIGHT_STATE_* */
unsigned new_light_state; /* Per-light bitmask */
unsigned new_tmu_state; /* Per-tmu bitmask */
unsigned flags; /* See DISP_3D_CTX_FLAG_* */
unsigned enabled_features; /* Driver must check! */
struct {
GLboolean alpha_test;
GLboolean blend;
GLboolean color_logic_op;
GLboolean color_material;
GLboolean cull_face;
GLboolean depth_test;
GLboolean fog;
GLboolean lighting;
GLboolean line_smooth;
GLboolean normalize;
GLboolean point_smooth;
GLboolean polygon_offset_fill;
GLboolean rescale_normal;
GLboolean scissor_test;
GLboolean stencil_test;
} enabled;
int lights_on;
struct light_state light[DISP_3D_NUM_LIGHTS];
struct {
struct {
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} ambient;
GLboolean twoside;
} lightmodel;
struct {
struct {
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} ambient;
struct {
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} diffuse;
struct {
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} specular;
struct {
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} emission;
disp_real shininess;
} material;
GLenum frontface;
GLenum cullface;
struct {
/* Buffer clear values */
disp_real r;
disp_real g;
disp_real b;
disp_real a;
disp_real depth;
GLint stencil;
} clear;
struct {
int x1;
int x2;
int y1;
int y2;
} cliprect;
struct {
disp_real near;
disp_real far;
GLenum func;
GLboolean mask;
} depth;
struct {
GLenum func;
GLenum fail;
GLenum zfail;
GLenum zpass;
GLuint testmask;
GLuint planemask;
GLint ref;
} stencil;
struct {
int x;
int y;
int width;
int height;
} viewport;
struct {
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} color;
struct {
GLboolean r;
GLboolean g;
GLboolean b;
GLboolean a;
} colormask;
struct {
GLenum func;
disp_real ref;
} alpha;
struct {
GLenum sfactor;
GLenum dfactor;
} blend;
struct {
GLenum mode;
disp_real density;
disp_real start;
disp_real end;
disp_real r;
disp_real g;
disp_real b;
disp_real a;
} fog;
GLenum rop;
GLenum shademodel;
struct {
disp_real x;
disp_real y;
disp_real z;
} normal;
/* Space for matrix stacks */
disp_real model_matrix[DISP_3D_MODEL_MATRIX_ENTRIES][16];
disp_real proj_matrix[DISP_3D_PROJ_MATRIX_ENTRIES][16];
disp_3d_matrix_flag model_matrix_flags[DISP_3D_MODEL_MATRIX_ENTRIES];
disp_3d_matrix_flag proj_matrix_flags[DISP_3D_PROJ_MATRIX_ENTRIES];
/* Indices into matrix stacks */
int model_matrix_stackptr;
int proj_matrix_stackptr;
disp_real point_size;
disp_real line_width;
struct {
disp_real factor;
disp_real units;
} polygon_offset;
disp_tmu_state_t tmu[DISP_3D_MAX_TMUS];
int enabled_tmus;
int complete_tmus;
disp_texture_t *textures[DISP_3D_MAX_TMUS];
disp_3d_pipeline_ctl_t pipeline_ctl;
uint32_t ddflags; /* Driver debugging flags */
uint32_t line_stipple; /* Only 16 bits used */
struct {
GLboolean dither;
GLboolean fsaa;
GLboolean reserved[2];
} enabled2;
uint32_t vtx_flags;
uint32_t reserved[28];
} disp_rendercontext_t;
typedef enum {
DISP_3D_CAP_ACCEL = 0x00000001, /* Driver has some form of 3D acceleration support */
DISP_3D_CAP_INDEPENDANT_PM = 0x00000020 /* 3D engine can be independently power managed (i.e. not tied to 2D engine) */
} disp_3d_cap_flag;
typedef struct disp_3d_caps {
disp_3d_cap_flag flags; /* See DISP_3D_CAP_* */
int fixed_point;
int max_vertices;
const char *extensions;
unsigned num_tmus;
unsigned max_line_width;
unsigned max_point_size;
unsigned max_line_width_aa;
unsigned max_point_size_aa;
unsigned reserved[1];
} disp_3d_caps_t;
typedef struct disp_draw_3dfuncs {
void * (*init)(disp_adapter_t *adapter, const char *options);
void (*fini)(void *handle);
void (*module_info)(disp_adapter_t *adapter, disp_module_info_t *info);
int (*query_caps)(void *handle, disp_3d_caps_t *caps);
int (*query_buffer_config)(void *handle,
int index, disp_rend_buffer_config_t *config);
void * (*create_context)(void *handle, disp_rendercontext_t *rctx,
disp_rend_context_params_t *params);
void (*destroy_context)(void *context);
void * (*create_target)(void *handle,
int cfg_index, int width, int height);
void (*destroy_target)(void *handle, void *target);
void (*create_texture)(void *context, disp_texture_t *tex);
void (*destroy_texture)(void *context, disp_texture_t *tex);
void (*set_tex_image)(void *context, disp_texture_t *tex,
int width, int height, int lod, unsigned format,
unsigned reqformat, int stride, const void *data, void *palette);
void (*set_tex_image_copy)(void *context, disp_texture_t *tex,
disp_surface_t *src, int sxoff, int syoff, int width, int height,
int lod, unsigned reqformat);
void (*update_tex_image)(void *context, disp_texture_t *tex,
int dxoff, int dyoff, int width, int height, int lod,
unsigned format, int stride, const void *data, void *palette);
void (*update_tex_image_copy)(void *context, disp_texture_t *tex,
disp_surface_t *src, int sxoff, int syoff, int dxoff, int dyoff,
int width, int height, int lod);
void (*read_image)(void *handle, int sxoff, int syoff,
int width, int height, unsigned dformat, int dstride,
disp_surface_t * src, void *dst, int y_order_ascending);
void (*flush)(void *context);
void (*wait_idle)(void *context);
void (*make_current)(void *context, void *target);
void (*set_draw_surface)(void *context, disp_surface_t *surf);
/* Notifies driver that span rendering is about to occur */
int (*span_prepare)(void *context);
GLbitfield (*clear)(void *context, GLbitfield buffer_mask);
int (*update_state)(void *context);
int (*set_power_mode)(disp_adapter_t *adapter, pm_power_mode_t mode);
/* Buffer Objects (optional - may be NULL) */
int (*bufobj_create)(void *context, disp_bufobj_t *obj);
void (*bufobj_destroy)(void *context, disp_bufobj_t *obj);
int (*bufobj_set_data)(void *context, disp_bufobj_t *obj,
uintptr_t offset, uintptr_t nbytes, const void *data, int realloc);
int (*bufobj_set_datasource)(void *context, disp_bufobj_t *obj,
unsigned array, uintptr_t offset,
unsigned datatype, int stride, int n_elements);
void (*bufobj_set_enabled)(void *context, unsigned array, int enabled);
/* Display Lists - UNSUPPORTED */
void * (*dlist_begin)(void *context);
int (*dlist_end)(void *context);
void (*dlist_execute)(void *context, void *dlist);
void (*dlist_destroy)(void *context, void *dlist);
/* Driver-specific extension support */
int (*state_set_enabled)(void *context, GLenum cap, int enabled,
int active_tmu, int active_client_tmu, intptr_t reserved);
void (*(*get_proc_addr)(void *context, const char *procname))();
int (*query_tex_format)(void *context,
GLenum type, int *bpp, unsigned *tex_format);
void (*reserved[5])(void);
} disp_draw_3dfuncs_t;
typedef int (*get_rendfuncs_t)(disp_adapter_t *adapter,
disp_draw_3dfuncs_t *funcs, int tabsize);
/* Main draw driver entry points */
extern SOFT3D_API int devg_get_rendfuncs(disp_adapter_t *adapter,
disp_draw_3dfuncs_t *funcs, int tabsize);
__END_DECLS
#endif /* _GRAPHICS_3D_H_INCLUDED */
#endif /* disabled in KPDA */

View File

@ -0,0 +1,362 @@
/*
* (c) 2020, SWD Embedded Systems Limited, http://www.kpda.ru
*/
/* Optimized inline routines for low-level graphics operations */
#ifndef _GRAPHICS_DINLINE_H_INCLUDED
#define _GRAPHICS_DINLINE_H_INCLUDED
/*
* The following macros are designed to allow, for example,
* DISP_MR_SWAP32(ptr++); to work without undesirable side effects.
*/
#ifdef __PPC__
static __inline__ uint32_t __attribute__((__unused__))
disp_mr_swap32(volatile uintptr_t __addr)
{
unsigned ret;
__asm__ __volatile__("lwbrx %0,0,%1" :
"=r" (ret) : "r" (__addr), "m" (__addr));
return ret;
}
static __inline__ uint16_t __attribute__((__unused__))
disp_mr_swap16(volatile uintptr_t __addr)
{
int ret;
__asm__ __volatile__("lhbrx %0,0,%1" :
"=r" (ret) : "r" (__addr), "m" (__addr));
return ret;
}
static __inline__ void __attribute__((__unused__))
disp_mw_swap32(volatile uintptr_t __addr, _Uint32t __data)
{
__asm__ __volatile__("stwbrx %1,0,%2" :
"=m" (__addr) : "r" (__data), "r" (__addr));
}
static __inline__ void __attribute__((__unused__))
disp_mw_swap16(volatile uintptr_t __addr, _Uint16t __data)
{
__asm__ __volatile__("sthbrx %1,0,%2" :
"=m" (__addr) : "r" (__data), "r" (__addr));
}
/*
* Bury these functions inside of macros, to work around a gcc 2.95.3 bug,
* which doesn't occur if the arg to disp_m* is a uintptr_t, instead of
* an actual pointer.
*/
#define DISP_MR_SWAP32(__addr) disp_mr_swap32((uintptr_t)(__addr))
#define DISP_MR_SWAP16(__addr) disp_mr_swap16((uintptr_t)(__addr))
#define DISP_MW_SWAP32(__addr, __val) disp_mw_swap32((uintptr_t)(__addr), __val)
#define DISP_MW_SWAP16(__addr, __val) disp_mw_swap16((uintptr_t)(__addr), __val)
#else
static __inline__ uint32_t __attribute__((__unused__))
DISP_MR_SWAP32(void *__ptr)
{
uint32_t __val = *(volatile uint32_t *)(__ptr);
return (((__val) >> 24) | (((__val) >> 8) & 0xff00) |
(((__val) & 0xff00) << 8) | ((__val) << 24));
}
static __inline__ uint16_t __attribute__((__unused__))
DISP_MR_SWAP16(void *__ptr)
{
uint16_t __val = *(volatile uint16_t *)(__ptr);
return (((__val) >> 8) | ((__val) << 8));
}
static __inline__ void __attribute__((__unused__))
DISP_MW_SWAP32(void *__ptr, uint32_t __v)
{
uint32_t __val = (__v);
__val = (__val >> 24 | (__val & 0xff0000) >> 8 |
(__val & 0xff00) << 8 | __val << 24);
*(volatile uint32_t *)(__ptr) = __val;
}
static __inline__ void __attribute__((__unused__))
DISP_MW_SWAP16(void *__ptr, uint16_t __v)
{
uint16_t __val = (__v);
__val = (__val >> 8 | __val << 8);
*(volatile uint16_t *)(__ptr) = __val;
}
#endif
#ifdef __LITTLEENDIAN__
#define DISP_MR_LE32(__ptr) (*(volatile uint32_t *)(__ptr))
#define DISP_MR_BE32(__ptr) DISP_MR_SWAP32(__ptr)
#define DISP_MW_LE32(__ptr, __val) (*(volatile uint32_t *)(__ptr) = (__val))
#define DISP_MW_BE32(__ptr, __val) DISP_MW_SWAP32(__ptr, __val)
#define DISP_MR_LE16(__ptr) (*(volatile uint16_t *)(__ptr))
#define DISP_MR_BE16(__ptr) DISP_MR_SWAP16(__ptr)
#define DISP_MW_LE16(__ptr, __val) (*(volatile uint16_t *)(__ptr) = (__val))
#define DISP_MW_BE16(__ptr, __val) DISP_MW_SWAP16(__ptr, __val)
#else
#define DISP_MR_LE32(__ptr) DISP_MR_SWAP32(__ptr)
#define DISP_MR_BE32(__ptr) (*(volatile uint32_t *)(__ptr))
#define DISP_MW_LE32(__ptr, __val) DISP_MW_SWAP32(__ptr, __val)
#define DISP_MW_BE32(__ptr, __val) (*(volatile uint32_t *)(__ptr) = (__val))
#define DISP_MR_LE16(__ptr) DISP_MR_SWAP16(__ptr)
#define DISP_MR_BE16(__ptr) (*(volatile uint16_t *)(__ptr))
#define DISP_MW_LE16(__ptr, __val) DISP_MW_SWAP16(__ptr, __val)
#define DISP_MW_BE16(__ptr, __val) (*(volatile uint16_t *)(__ptr) = (__val))
#endif
__BEGIN_DECLS
#define __USE_C_FALLBACKS
#if defined (__GNUC__) || defined(__INTEL_COMPILER)
#if defined (__X86__)
#undef __USE_C_FALLBACKS
static inline void disp_memcpy(void *dst, void *src, int len)
{
__asm__ __volatile__ (
".align 4 \n\t"
"cld \n\t"
"cmpl $8, %%edx \n\t"
"jl 0f \n\t"
"3: \n\t"
".align 4 \n\t"
"testl $3, %%edi \n\t"
"jz 1f \n\t"
"movsb \n\t"
"decl %%edx \n\t"
"jz 2f \n\t"
"jnz 3b \n\t"
"0: \n\t"
".align 4 \n\t"
"movl %%edx, %%ecx \n\t"
"rep \n\t"
"movsb \n\t"
"jmp 2f \n\t"
"1: \n\t"
".align 4 \n\t"
"movl %%edx, %%ecx \n\t"
"shrl $2, %%ecx \n\t"
"rep \n\t"
"movsl \n\t"
"4: \n\t"
".align 4 \n\t"
"andl $3, %%edx \n\t"
"jz 2f \n\t"
"movsb \n\t"
"decb %%dl \n\t"
"jmp 4b \n\t"
"2: \n\t"
".align 4 \n\t"
: "=D"(dst), "=S"(src), "=d"(len) : "D"(dst), "S"(src), "d"(len) :
"ecx", "memory");
}
static inline void disp_memcpy_r(void *dst, void *src, int len)
{
__asm__ __volatile__ (
"std \n\t"
"cmpl $8, %%edx \n\t"
"jge 0f \n\t"
"movl %%edx, %%ecx \n\t"
"rep \n\t"
"movsb \n\t"
"jmp 1f \n\t"
/* Move (edi+1) & 3 bytes with movsb. */
"0: \n\t"
".align 4 \n\t"
"movl $3, %%eax \n\t"
"movl %%edi, %%ecx \n\t"
"incl %%ecx \n\t"
"andl %%eax, %%ecx \n\t"
"subl %%ecx, %%edx \n\t"
"rep \n\t"
"movsb \n\t"
/* Adjust edi & esi to point to *start* of nearest long. */
/* Move (edx / 4) longs with movsd. */
/* Adjust edi & esi to point back to end of long. */
"subl %%eax, %%edi \n\t"
"subl %%eax, %%esi \n\t"
"movl %%edx, %%ecx \n\t"
"shrl $2, %%ecx \n\t"
"rep \n\t"
"movsl \n\t"
"addl %%eax, %%edi \n\t"
"addl %%eax, %%esi \n\t"
/* Move remaining bytes. */
"movl %%edx, %%ecx \n\t"
"andl %%eax, %%ecx \n\t"
"jz 1f \n\t"
"rep \n\t"
"movsb \n\t"
"1: \n\t"
".align 4 \n\t"
"cld \n\t"
: "=D"(dst), "=S"(src), "=d"(len) : "D"(dst), "S"(src), "d"(len) :
"eax", "ecx", "memory");
}
static inline void disp_memset16(void *dst, uint16_t val, int len)
{
__asm__ __volatile__ (
"cmpl $8, %%edx \n\t"
"jle 0f \n\t"
"movl %%eax, %%ecx \n\t"
"rorl $16, %%eax \n\t"
"movw %%cx, %%ax \n\t"
"2: \n\t"
".align 4 \n\t"
"testl $3, %%edi \n\t"
"jz 1f \n\t"
"stosw \n\t"
"decl %%edx \n\t"
"jmp 2b \n\t"
"1: \n\t"
".align 4 \n\t"
"movl %%edx, %%ecx \n\t"
"shrl $1, %%ecx \n\t"
"andl $1, %%edx \n\t"
"rep \n\t"
"stosl \n\t"
"0: \n\t"
".align 4 \n\t"
"testl %%edx, %%edx \n\t"
"jz 3f \n\t"
"movl %%edx, %%ecx \n\t"
"rep \n\t"
"stosw \n\t"
"3: \n\t"
".align 4 \n\t"
: "=D"(dst), "=a"(val), "=d"(len) : "D"(dst), "a"(val), "d"(len) :
"ecx", "memory");
};
#endif /* __X86__ */
#elif defined (__WATCOMC__)
#undef __USE_C_FALLBACKS
void disp_memcpy(void *dst, void *src, int len);
#pragma aux disp_memcpy = \
" cmp edx, 8 ",\
" jl QByteCopy ",\
"StartTest: ",\
" test edi, 3 ",\
" jz EvenStart ",\
" movsb ",\
" dec edx ",\
" jz Done ",\
" jmp StartTest ",\
"QByteCopy: ",\
" mov ecx, edx ",\
"QByteCopy2: ",\
" rep movsb ",\
" jmp Done ",\
"EvenStart: ",\
" mov ecx, edx ",\
" shr ecx, 2 ",\
"DoubleCopy: ",\
" rep movsd ",\
"ByteCopy: ",\
" and edx, 3 ",\
" jz Done ",\
" movsb ",\
" dec dl ",\
" jmp ByteCopy ",\
"Done: "\
parm nomemory [edi] [esi] [edx] \
modify [edi esi ecx edx];
void disp_memcpy_r(void *dst, void *src, int len);
#pragma aux disp_memcpy_r = \
" std ",\
" cmp edx, 8 ",\
" jge StartTest ",\
\
" mov ecx, edx ",\
" rep movsb ",\
" jmp Done ",\
/* move (edi+1) & 3 bytes with movsb */ \
"StartTest: ",\
" mov eax, 3 ",\
" mov ecx,edi ",\
" inc ecx ",\
" and ecx,eax ",\
" sub edx,ecx ",\
" rep movsb ",\
/* adjust edi & esi to point to */ \
/* *start* of nearest long */ \
/* move (edx / 4) longs with movsd */ \
/* adjust edi & esi to point back to end of long */ \
" sub edi, eax ",\
" sub esi, eax ",\
" mov ecx, edx ",\
" shr ecx, 2 ",\
" rep movsd ",\
" add edi, eax ",\
" add esi, eax ",\
/* move remaining bytes */ \
" mov ecx, edx ",\
" and ecx, eax ",\
" jz Done ",\
" rep movsb ",\
"Done: ",\
" cld ",\
parm nomemory [edi] [esi] [edx] \
modify [edi esi eax ecx edx];
void disp_memset16(void *dst, unsigned short val, int len);
#pragma aux disp_memset16 = \
" cmp edx, 8 ",\
" jle ByteCopy ",\
" mov ecx, eax ",\
" ror eax, 16 ",\
" mov ax, cx ",\
"StartTest: ",\
" test edi, 3 ",\
" jz EvenStart ",\
" stosw ",\
" dec edx ",\
" jmp StartTest ",\
"EvenStart: ",\
" mov ecx, edx ",\
" shr ecx, 1 ",\
" and edx, 1 ",\
" rep stosd ",\
"ByteCopy: ",\
" test edx, edx ",\
" jz Done ",\
" mov ecx, edx ",\
" rep stosw ",\
"Done: "\
parm nomemory [edi] [ax] [edx] \
modify [edi eax ecx edx];
#endif /* __WATCOMC__ */
#ifdef __USE_C_FALLBACKS
#define disp_memcpy(dst, src, len) memcpy(dst, src, len)
extern void disp_memcpy_r(void *dst, void *src, int len);
extern void disp_memset16(void *dst, disp_color_t color, int len);
#endif /* __USE_C_FALLBACKS */
__END_DECLS
#endif /* _GRAPHICS_DINLINE_H_INCLUDED */

View File

@ -0,0 +1,494 @@
/*
* (c) 2020, SWD Embedded Systems Limited, http://www.kpda.ru
*/
#ifndef _GRAPHICS_DISPLAY_H_INCLUDED
#define _GRAPHICS_DISPLAY_H_INCLUDED
#ifndef __TYPES_H_INCLUDED
#include <sys/types.h>
#endif
#ifdef __QNXNTO__
#ifndef __INTTYPES_H_INCLUDED
#include <inttypes.h>
#endif
#endif
#ifndef __GULLIVER_H_INCLUDED
#include <gulliver.h>
#endif