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

📄 xf86dmc.c.org

📁 一份介绍在S3C2410上液晶屏驱动程序的实现
💻 ORG
📖 第 1 页 / 共 2 页
字号:
				sleep(1);	/* touch need ca. 500ms delay !!! */				XisbBlockDuration (priv->buffer, 500000);				if ( DMCSendPacket(priv, buf, 2) == Success )				{					/* wait for right response */					priv->lex_mode = DMC_Response0;					if (DMCGetPacket (priv) == Success )					{						if ( priv->packet[0] == 0x06 )						{							buf[0] = 0x31;							DMCSendPacket(priv,buf,1);							priv->lex_mode = DMC_Response0;							xf86Msg(X_ERROR, "DMC-Touch found\n");						}						else						{							xf86Msg(X_ERROR, "DMC-Touch found\n");							return (!Success);						}					}					else					{						xf86Msg(X_ERROR, "DMC-Touch found\n");						return (!Success);					}				}				else				{					xf86Msg(X_ERROR, "DMC-Touch found\n");					return (!Success);				}			}		}		XisbBlockDuration (priv->buffer, -1);		priv->lex_mode = DMC_byte0;				xf86FlushInput(pInfo->fd);		AddEnabledDevice (pInfo->fd);		dev->public.on = TRUE;		return (Success);			case DEVICE_OFF:	case DEVICE_CLOSE:		if (pInfo->fd != -1)			{ 				RemoveEnabledDevice (pInfo->fd);				if (priv->buffer)					{						XisbFree(priv->buffer);						priv->buffer = NULL;					}				xf86CloseSerial(pInfo->fd);			}		dev->public.on = FALSE;		return (Success);	default:		return (BadValue);	}}/*  * The ReadInput function will have to be tailored to your device */static voidReadInput (InputInfoPtr pInfo){	DMCPrivatePtr priv = (DMCPrivatePtr) (pInfo->private);	int x,y;	unsigned char opck[ DMC_PACKET_SIZE ];	/* 	 * set blocking to -1 on the first call because we know there is data to	 * read. Xisb automatically clears it after one successful read so that	 * succeeding reads are preceeded buy a select with a 0 timeout to prevent	 * read from blocking indefinately.	 */	XisbBlockDuration (priv->buffer, -1);	while (1)	{		memcpy(opck,priv->packet,5);		if ( DMCGetPacket (priv) != Success)			break;		if ( priv->packet[0] == 0x11 )			priv->pen_down=1;		else			priv->pen_down=0;		if ( priv->swap_xy)		{			y = priv->packet[1]*256+priv->packet[2];			x = priv->packet[3]*256+priv->packet[4];		}		else		{			x = priv->packet[1]*256+priv->packet[2];			y = priv->packet[3]*256+priv->packet[4];		}		priv->packet[0] = priv->pen_down ? 0x01 : 0x00;		if (priv->reporting_mode == TS_Scaled)		{				x = xf86ScaleAxis (x, 0, priv->screen_width, priv->min_x,					   priv->max_x);                        y = xf86ScaleAxis (y, 0, priv->screen_height, priv->min_y,					   priv->max_y);                }        				xf86XInputSetScreen (pInfo, priv->screen_num, x, y);		if ((priv->proximity == FALSE) && (priv->packet[0] & 0x01))		{			priv->proximity = TRUE;			xf86PostProximityEvent (pInfo->dev, 1, 0, 2, x, y);		}              			             /*                 * Send events.                 *                 * We *must* generate a motion before a button change if pointer                 * location has changed as DIX assumes this. This is why we always                 * emit a motion, regardless of the kind of packet processed.                 */                xf86PostMotionEvent (pInfo->dev, TRUE, 0, 2, x, y);                /*                 * Emit a button press or release.                 */                if ((priv->button_down == FALSE) && (priv->packet[0] & 0x01))                {                        xf86PostButtonEvent (pInfo->dev, TRUE,					     priv->button_number, 1, 0, 2, x, y);                        priv->button_down = TRUE;                }                if ((priv->button_down == TRUE) && !(priv->packet[0] & 0x01))                {                        xf86PostButtonEvent (pInfo->dev, TRUE,					     priv->button_number, 0, 0, 2, x, y);                        priv->button_down = FALSE;                }                /*                 * the untouch should always come after the button release                 */                if ((priv->proximity == TRUE) && !(priv->packet[0] & 0x01))                {                        priv->proximity = FALSE;                        xf86PostProximityEvent (pInfo->dev, 0, 0, 2, x, y);                }	}}/*  * The ControlProc function may need to be tailored for your device */static intControlProc (InputInfoPtr pInfo, xDeviceCtl * control){	xDeviceTSCalibrationCtl *c = (xDeviceTSCalibrationCtl *) control;	DMCPrivatePtr priv = (DMCPrivatePtr) (pInfo->private);        priv->min_x = c->min_x;        priv->max_x = c->max_x;        priv->min_y = c->min_y;        priv->max_y = c->max_y; 	return (Success);}/*  * the CloseProc should not need to be tailored to your device */static voidCloseProc (InputInfoPtr pInfo){}/*  * The SwitchMode function may need to be tailored for your device */static intSwitchMode (ClientPtr client, DeviceIntPtr dev, int mode){	InputInfoPtr pInfo = dev->public.devicePrivate;        DMCPrivatePtr priv = (DMCPrivatePtr) (pInfo->private);	if ((mode == TS_Raw) || (mode == TS_Scaled))        {                priv->reporting_mode = mode;                return (Success);        }        else if ((mode == SendCoreEvents) || (mode == DontSendCoreEvents))        {                xf86XInputSetSendCoreEvents (pInfo, (mode == SendCoreEvents));                return (Success);        }        else                return (!Success);   }/*  * The ConvertProc function may need to be tailored for your device. * This function converts the device's valuator outputs to x and y coordinates * to simulate mouse events. */static BoolConvertProc (InputInfoPtr pInfo,			 int first,			 int num,			 int v0,			 int v1,			 int v2,			 int v3,			 int v4,			 int v5,			 int *x,			 int *y){	DMCPrivatePtr priv = (DMCPrivatePtr) (pInfo->private);	if (priv->reporting_mode == TS_Raw)	{                *x = xf86ScaleAxis (v0, 0, priv->screen_width, priv->min_x,                                                        priv->max_x);                *y = xf86ScaleAxis (v1, 0, priv->screen_height, priv->min_y,                                                        priv->max_y);        }        else        {                *x = v0;                *y = v1;	}	return (TRUE);}/*  * the QueryHardware fuction should be tailored to your device to * verify the device is attached and functional and perform any * needed initialization. */static BoolQueryHardware (DMCPrivatePtr priv){	/* Maybe once we get the hardware to actually respond correctly to its 	   configuration 'packets' */	return (Success);}/*  * This function should be renamed for your device and tailored to handle * your device's protocol. */static BoolDMCGetPacket (DMCPrivatePtr priv){	int count = 0;	int c;	while ((c = XisbRead (priv->buffer)) >= 0)	{		/* 		 * fail after 500 bytes so the server doesn't hang forever if a		 * device sends bad data.		 */		if (count++ > 500)			return (!Success);		switch (priv->lex_mode)		{		case DMC_byte0:			if ((( c & 0x3f ) != 0x11 ) &&				(( c & 0x3f ) != 0x10 ))					return (!Success);			priv->packet[0] = (unsigned char) c & 0x3f;			priv->lex_mode = DMC_byte1;			break;		case DMC_byte1:			priv->packet[1] = (unsigned char) c;			priv->lex_mode = DMC_byte2;			break;					case DMC_byte2:			priv->packet[2] = (unsigned char) c;			priv->lex_mode = DMC_byte3;			break;		case DMC_byte3:			priv->packet[3] = (unsigned char) c;			priv->lex_mode = DMC_byte4;			break;		case DMC_byte4:			priv->packet[4] = (unsigned char) c;			priv->lex_mode = DMC_byte0;			return (Success);			break;		case DMC_Response0:			priv->packet[0] = (unsigned char) c;			return (Success);			break;		}	}	return (!Success);}static BoolDMCSendPacket (DMCPrivatePtr priv, unsigned char *buf, int len){	int				count = 0;	while ( len > 0 )	{		if ( XisbWrite(priv->buffer, buf, 1) == 1 )		{			buf++;			len--;			continue;		}		if ( count++ > 500 )			break;	}	return (len ? !Success : Success);}static voidDMCPtrCtrl(DeviceIntPtr device, PtrCtrl *ctrl){  /* I have no clue what this does, except that registering it stops the      X server segfaulting in ProcGetPointerMapping()     Ho Hum.  */}

⌨️ 快捷键说明

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