Re: Calling usb_bulk_msg inside usbtouch_process_pkt is causing kernel panic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Greg,

This is my packet process function. This is a multitouch controller. In every frame I need to get touch data and if any touch is available to be inject into the system, that is done in this method.

static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch, unsigned char *pkt, int len)
{
    int touch=0,currentTouch=0,transferedBytes=0;
    PDPX_TOUCH Touch;

    struct usbtouch_device_info *type = usbtouch->type;
    struct dpx_priv *priv = usbtouch->priv;
    struct usb_device *usbdev = interface_to_usbdev(usbtouch->interface);

    if (!type->read_data(usbtouch, pkt))
        return;

    tCurrent = jiffies;
    elapsed = tCurrent-tInitial;
    elapsed = elapsed * 1000 / HZ;

    if (elapsed>1000)
    {
priv->context->State.Acquisition.FrameRate = priv->context->Data.Acquisition.Frames;
        priv->context->Data.Acquisition.Frames = 0;

        tInitial = tCurrent;
    }

    priv->context->State.Acquisition.FrameCounter++;

    if (usbdev)
    {
if (priv->context->State.Acquisition.FrameCounter>DPX_INTERVAL_FRAMES_BETWEEN_AUTO_SETUP)
        {
usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, (int)0x02), 0x00, 8, &transferedBytes, 1000);
            priv->context->State.Acquisition.FrameCounter = 0;
        }
    }

if (!priv->context->State.Enabled || !priv->context->State.Acquisition.Status)
        return;

for (currentTouch=0;currentTouch<DPX_TOUCH_MAX_COUNT && touch<priv->context->State.Acquisition.TouchPoints;++currentTouch)
    {
        Touch = priv->context->State.Touches + currentTouch;

if(Touch->CurrentState==DPX_TOUCH_STATE_ACTIVE && Touch->FramesActive>1)
        {
            Touch->ReportedState = DPX_TOUCH_STATE_ACTIVE;

            if (touch==0)
            {
//input_report_key(usbtouch->input, BTN_TOUCH, usbtouch->touch); input_report_abs(usbtouch->input, ABS_X, Touch->WindowsPosition.X); input_report_abs(usbtouch->input, ABS_Y, Touch->WindowsPosition.Y);
            }

            input_mt_slot(usbtouch->input, Touch->Id);

input_report_abs(usbtouch->input, ABS_MT_TRACKING_ID, Touch->Id); input_report_abs(usbtouch->input, ABS_MT_TOUCH_MAJOR, Touch->Pressure); input_report_abs(usbtouch->input, ABS_MT_POSITION_X, Touch->WindowsPosition.X); input_report_abs(usbtouch->input, ABS_MT_POSITION_Y, Touch->WindowsPosition.Y);

//printk(KERN_INFO "id: %d x:%d y:%d pressure: %d",Touch->Id,Touch->ReportedPosition.X,Touch->ReportedPosition.Y,Touch->Pressure);

            touch++;
        }
else if(Touch->CurrentState==DPX_TOUCH_STATE_INACTIVE && Touch->ReportedState==DPX_TOUCH_STATE_ACTIVE)
        {
            Touch->ReportedState = DPX_TOUCH_STATE_INACTIVE;

            input_mt_slot(usbtouch->input, Touch->Id);
            input_report_abs(usbtouch->input, ABS_MT_TRACKING_ID, -1);

            touch++;
        }
    }

    if (touch>0)
    {
        input_sync(usbtouch->input);
    }
}

On 01/03/2012 05:47 PM, Greg KH wrote:

Why is that the only time you have access to the device?

What is causing you to want to do this type of thing?  Can't you trigger
off of that?

I need to make this in a point equivalent to a run loop. Do you know what I mean?
That would work, as would a waitqueue.
Yeah, I was looking to workqueues as being the most similar thing to a timer. Is that ok as well?


Thanks

Nuno
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux