Пример #1
0
static void xpad_irq_in(struct urb *urb)
{
	struct usb_xpad *xpad = urb->context;
	struct device *dev = &xpad->intf->dev;
	int retval, status;

	status = urb->status;

	switch (status) {
	case 0:
		/* success */
		break;
	case -ECONNRESET:
	case -ENOENT:
	case -ESHUTDOWN:
		/* this urb is terminated, clean up */
		dev_dbg(dev, "%s - urb shutting down with status: %d\n",
			__func__, status);
		return;
	default:
		dev_dbg(dev, "%s - nonzero urb status received: %d\n",
			__func__, status);
		goto exit;
	}

	switch (xpad->xtype) {
	case XTYPE_XBOX360:
		trace_joystick_irq("Joystick_xpad360_process_packet");
		xpad360_process_packet(xpad, 0, xpad->idata);
		break;
	case XTYPE_XBOX360W:
		trace_joystick_irq("Joystick_xpad360w_process_packet");
		xpad360w_process_packet(xpad, 0, xpad->idata);
		break;
	default:
		trace_joystick_irq("Joystick_xpad_process_packet");
		xpad_process_packet(xpad, 0, xpad->idata);
	}

exit:
	trace_joystick_irq("Joystick_xpad_usb_submit_urb");
	retval = usb_submit_urb(urb, GFP_ATOMIC);
	if (retval)
		dev_err(dev, "%s - usb_submit_urb failed with result %d\n",
			__func__, retval);
}
Пример #2
0
static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
{
	/* Presence change */
	if (data[0] & 0x08) {
		if (data[1] & 0x80) {
			xpad->pad_present = 1;
			usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
		} else
			xpad->pad_present = 0;
	}

	/* Valid pad data */
	if (!(data[1] & 0x1))
		return;

	xpad360_process_packet(xpad, cmd, &data[4]);
}
Пример #3
0
static void xpad_irq_in(struct urb *urb)
{
	struct usb_xpad *xpad = urb->context;
	int retval, status;

	status = urb->status;

	switch (status) {
	case 0:
		/* success */
		break;
	case -ECONNRESET:
	case -ENOENT:
	case -ESHUTDOWN:
		/* this urb is terminated, clean up */
		dbg("%s - urb shutting down with status: %d",
			__func__, status);
		return;
	case -EPIPE:
	case -EPROTO:
		schedule_work(&xpad->submit_urb);
		return;
	default:
		dbg("%s - nonzero urb status received: %d",
			__func__, status);
		goto exit;
	}

	switch (xpad->xtype) {
	case XTYPE_XBOX360:
		xpad360_process_packet(xpad, 0, xpad->idata);
		break;
	case XTYPE_XBOX360W:
		xpad360w_process_packet(xpad, 0, xpad->idata);
		break;
	default:
		xpad_process_packet(xpad, 0, xpad->idata);
	}

exit:
	retval = usb_submit_urb(urb, GFP_ATOMIC);
	if (retval)
		err ("%s - usb_submit_urb failed with result %d",
		     __func__, retval);
}
Пример #4
0
static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
{
	/* Presence change */
	if (data[0] & 0x08) {
		if (data[1] & 0x80) {
			xpad->pad_present = 1;
			xpad_send_led_command(xpad,
				0x42 + ((xpad->interface_number / 2) & 3), 0);
		} else
			xpad->pad_present = 0;
	}

	/* Valid pad data */
	if (!(data[1] & 0x1))
		return;

	xpad360_process_packet(xpad, cmd, &data[4]);
}
Пример #5
0
/*
 * xpad360w_process_packet
 *
 * Completes a request by converting the data into events for the
 * input subsystem. It is version for xbox 360 wireless controller.
 *
 * Byte.Bit
 * 00.1 - Status change: The controller or headset has connected/disconnected
 *                       Bits 01.7 and 01.6 are valid
 * 01.7 - Controller present
 * 01.6 - Headset present
 * 01.1 - Pad state (Bytes 4+) valid
 *
 */
static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
{
	int presence;

	/* Presence change */
	if (data[0] & 0x08) {
		presence = (data[1] & 0x80) != 0;

		if (xpad->pad_present != presence) {
			xpad->pad_present = presence;
			schedule_work(&xpad->work);
		}
	}

	/* Valid pad data */
	if (!(data[1] & 0x1))
		return;

	xpad360_process_packet(xpad, cmd, &data[4]);
}
Пример #6
0
/*
 * xpad360w_process_packet
 *
 * Completes a request by converting the data into events for the
 * input subsystem. It is version for xbox 360 wireless controller.
 *
 * Byte.Bit
 * 00.1 - Status change: The controller or headset has connected/disconnected
 *                       Bits 01.7 and 01.6 are valid
 * 01.7 - Controller present
 * 01.6 - Headset present
 * 01.1 - Pad state (Bytes 4+) valid
 *
 */
static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
{
	/* Presence change */
	if (data[0] & 0x08) {
		if (data[1] & 0x80) {
			xpad->pad_present = 1;
			/*
			 * Light up the segment corresponding to
			 * controller number.
			 */
			xpad_identify_controller(xpad);
		} else
			xpad->pad_present = 0;
	}

	/* Valid pad data */
	if (!(data[1] & 0x1))
		return;

	xpad360_process_packet(xpad, cmd, &data[4]);
}
Пример #7
0
static void xpad_irq_in(struct urb *urb)  //检测 urb状态的函数
{
    struct usb_xpad *xpad = urb->context; //获取urb的内容  里面存放着usb_xpad的结构信息
    struct device *dev = &xpad->intf->dev; //根据usb设备接口获取该设备信息 intf为usb设备接口  dev是详细的设备信息
    int retval, status;

    status = urb->status; //urb的返回值

    switch (status) //判断urb的返回值
    {
    case 0:
        //成功
        break;
    case -ECONNRESET:
    case -ENOENT:
    case -ESHUTDOWN:
        //这个urb结束了
        dev_dbg(dev, "%s - urb shutting down with status: %d\n",
                __func__, status);
        return;
    default:
        dev_dbg(dev, "%s - nonzero urb status received: %d\n",
                __func__, status);
        goto exit;
    }


    xpad360_process_packet(xpad, 0, xpad->idata); //处理设备的raw packet


exit:
    retval = usb_submit_urb(urb, GFP_ATOMIC);//提交urb
    if (retval) //出错
        dev_err(dev, "%s - usb_submit_urb failed with result %d\n",
                __func__, retval);
}