⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xf86dmc.c.org

📁 一份介绍在S3C2410上液晶屏驱动程序的实现
💻 ORG
📖 第 1 页 / 共 2 页
字号:
/*  * Copyright (c) 1999  Machine Vision Holdings Incorporated * Author: Mayk Langer <langer@vsys.de> * * Template driver used: Copyright (c) 1998  Metro Link Incorporated * * 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, cpy, 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 X CONSORTIUM 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. * * Except as contained in this notice, the name of the Metro Link shall not be * used in advertising or otherwise to promote the sale, use or other dealings * in this Software without prior written authorization from Metro Link. * *//* $XFree86: xc/programs/Xserver/hw/xfree86/input/dmc/xf86DMC.c,v 1.2 2001/11/26 16:25:52 dawes Exp $ */#define _DMC_C_#include <misc.h>#include <xf86.h>#define NEED_XF86_TYPES#include <xf86_ansic.h>#include <xf86_OSproc.h>#include <xf86Xinput.h>#include <xisb.h>#include <exevents.h>#include "xf86DMC.h"InputDriverRec DMC = {        1,        "dmc",        NULL,        DMCPreInit,        /*DMCUnInit*/NULL,        NULL,        0};        #ifdef XFree86LOADERstatic XF86ModuleVersionInfo VersionRec ={	"dmc",	MODULEVENDORSTRING,	MODINFOSTRING1,	MODINFOSTRING2,	XF86_VERSION_CURRENT,	1, 0, 0,	ABI_CLASS_XINPUT,	ABI_XINPUT_VERSION,	MOD_CLASS_XINPUT,	{0, 0, 0, 0}				/* signature, to be patched into the file by								 * a tool */};static const char *reqSymbols[] = {	"AddEnabledDevice",	"ErrorF",	"InitButtonClassDeviceStruct",	"InitProximityClassDeviceStruct",	"InitValuatorAxisStruct",	"InitValuatorClassDeviceStruct",	"InitPtrFeedbackClassDeviceStruct",	"RemoveEnabledDevice",	"Xcalloc",	"Xfree",	"XisbBlockDuration",	"XisbFree",	"XisbNew",	"XisbRead",	"XisbTrace",	"screenInfo",	"xf86AddInputDriver",	"xf86AllocateInput",	"xf86CloseSerial",	"xf86CollectInputOptions",	"xf86ErrorFVerb",	"xf86FindOptionValue",	"xf86GetMotionEvents",	"xf86GetVerbosity",	"xf86MotionHistoryAllocate",	"xf86NameCmp",	"xf86OpenSerial",	"xf86OptionListCreate",	"xf86OptionListMerge",	"xf86OptionListReport",	"xf86PostButtonEvent",	"xf86PostMotionEvent",	"xf86PostProximityEvent",	"xf86ProcessCommonOptions",	"xf86ScaleAxis",	"xf86SetIntOption",	"xf86SetStrOption",	"xf86XInputSetScreen",	"xf86XInputSetSendCoreEvents",	NULL};static pointerDMCSetupProc(	pointer module,			pointer options,			int *errmaj,			int *errmin ){	xf86LoaderReqSymLists(reqSymbols, NULL);	xf86AddInputDriver(&DMC, module, 0);	return (pointer) 1;}XF86ModuleData dmcModuleData = { &VersionRec, DMCSetupProc, NULL };#endif /* XFree86LOADER *//*  * Be sure to set vmin appropriately for your device's protocol. You want to * read a full packet before returning */static const char *default_options[] ={	/*	"Device", "/dev/ttyS1",*/	"BaudRate", "9600",	"StopBits", "1",	"DataBits", "8",	"Parity", "None",	"Vmin", "3",	"Vtime", "1",	"FlowControl", "None",	NULL,};/***************************************************************************** *	Function Definitions ****************************************************************************/static InputInfoPtrDMCPreInit(InputDriverPtr drv, IDevPtr dev, int flags){              	InputInfoPtr pInfo;   	DMCPrivatePtr priv = xcalloc (1, sizeof (DMCPrivateRec));	char *s;	if (!priv)		return NULL;	if (!(pInfo = xf86AllocateInput(drv, 0))) {		xfree(priv);		return NULL;	}  	priv->min_x = 0;	priv->max_x = 1024;	priv->min_y = 768;	priv->max_y = 0;	priv->screen_num = 0;	priv->screen_width = -1;	priv->screen_height = -1;	priv->lex_mode = DMC_byte0;	priv->swap_xy = 0;	priv->button_down = FALSE;	priv->button_number = 1;	priv->proximity = FALSE;	priv->pen_down = 0;	pInfo->type_name = XI_TOUCHSCREEN;	pInfo->device_control = DeviceControl;	pInfo->read_input = ReadInput;	pInfo->control_proc = ControlProc;	pInfo->close_proc = CloseProc;	pInfo->switch_mode = SwitchMode;	pInfo->conversion_proc = ConvertProc;	pInfo->dev = NULL;	pInfo->private = priv;	pInfo->private_flags = 0;	pInfo->flags = XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS;	pInfo->conf_idev = dev;	xf86CollectInputOptions(pInfo, default_options, NULL);	xf86OptionListReport( pInfo->options );	pInfo->fd = xf86OpenSerial (pInfo->options);	if (pInfo->fd == -1)	{		ErrorF ("DMC driver unable to open device\n");		goto SetupProc_fail;	}	xf86CloseSerial(pInfo->fd);	/* 	 * Process the options for your device like this	 */	priv->min_x = xf86SetIntOption( pInfo->options, "MinX", 0 );	priv->max_x = xf86SetIntOption( pInfo->options, "MaxX", 1024 );	priv->min_y = xf86SetIntOption( pInfo->options, "MinY", 768 );	priv->max_y = xf86SetIntOption( pInfo->options, "MaxY", 0 );	priv->screen_num = xf86SetIntOption( pInfo->options, "ScreenNumber", 0 );	priv->button_number = xf86SetIntOption( pInfo->options, "ButtonNumber", 1 );	priv->swap_xy = xf86SetIntOption( pInfo->options, "SwapXY", 0 );	priv->buffer = NULL;	s = xf86FindOptionValue (pInfo->options, "ReportingMode");	if ((s) && (xf86NameCmp (s, "raw") == 0))		priv->reporting_mode = TS_Raw;	else		priv->reporting_mode = TS_Scaled;	priv->proximity = FALSE;	priv->button_down = FALSE;	priv->lex_mode = DMC_byte0;	if (QueryHardware (priv) != Success)	{		ErrorF ("Unable to query/initialize DMC hardware.\n");		goto SetupProc_fail;	}	/* this results in an xstrdup that must be freed later */	pInfo->name = xf86SetStrOption( pInfo->options, "DeviceName", "DMC");	xf86ProcessCommonOptions(pInfo, pInfo->options);	pInfo->flags |= XI86_CONFIGURED;	return (pInfo);  SetupProc_fail:	if ((pInfo) && (pInfo->fd))		xf86CloseSerial (pInfo->fd);	if ((pInfo) && (pInfo->name))		xfree (pInfo->name);	if ((priv) && (priv->buffer))		XisbFree (priv->buffer);	if (priv)		xfree (priv);	return (pInfo);}static BoolDeviceControl (DeviceIntPtr dev, int mode){	InputInfoPtr pInfo = dev->public.devicePrivate;	DMCPrivatePtr priv = (DMCPrivatePtr) (pInfo->private);	unsigned char map[] =	{0, 1};	switch (mode)	{	case DEVICE_INIT:		/*		 * these have to be here instead of in the SetupProc, because when the		 * SetupProc is run at server startup, screenInfo is not setup yet		 */		priv->screen_width = screenInfo.screens[priv->screen_num]->width;		priv->screen_height = screenInfo.screens[priv->screen_num]->height;				/*		 * Device reports button press for 1 button.		 */		if (InitButtonClassDeviceStruct (dev, 1, map) == FALSE)			{				ErrorF ("Unable to allocate DMC ButtonClassDeviceStruct\n");				return !Success;			}				/*		 * Device reports motions on 2 axes in absolute coordinates.		 * Axes min and max values are reported in raw coordinates.		 */		if (InitValuatorClassDeviceStruct (dev, 2, xf86GetMotionEvents,						   pInfo->history_size, Absolute) == FALSE)			{				ErrorF ("Unable to allocate DMC ValuatorClassDeviceStruct\n");				return !Success;			}		else			{				InitValuatorAxisStruct (dev, 0, priv->min_x, priv->max_x,							9500,							0 /* min_res */ ,							9500 /* max_res */ );				InitValuatorAxisStruct (dev, 1, priv->min_y, priv->max_y,							10500,							0 /* min_res */ ,							10500 /* max_res */ );			}				if (InitProximityClassDeviceStruct (dev) == FALSE)			{				ErrorF ("unable to allocate DMC ProximityClassDeviceStruct\n");				return !Success;			}				if (InitPtrFeedbackClassDeviceStruct(dev, DMCPtrCtrl) == FALSE)			{				ErrorF ("unable to allocate DMC PtrFeedbackClassDeviceStruct\n");				return !Success;			}				/* 		 * Allocate the motion events buffer.		 */		xf86MotionHistoryAllocate (pInfo);		return (Success);			case DEVICE_ON:		pInfo->fd = xf86OpenSerial(pInfo->options);		if (pInfo->fd == -1)		{			xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);			return (!Success);		}		else 		{			priv->buffer = XisbNew(pInfo->fd, 64);			if (!priv->buffer) 			{				xf86CloseSerial(pInfo->fd);				pInfo->fd = -1;				return (!Success);			}			else			{				unsigned char	buf[2] = { 0x05, 0x40 };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -