UVC摄像头驱动

中文QNX 讨论: 欢迎大家灌水,讨论有关QNX 问题。

UVC摄像头驱动

帖子一般般_6133 » 周二 9月 10, 2013 8:32 pm

各位好!有没有谁用过usb ddk来开发UVC标准摄像头的驱动程序呀?我在commit参数、选择1接口的6号可选接口之后使用usbd_setup_isochronous()没有收到数据。这要怎么处理,有没有人知道啊?求助
一般般_6133
New Member
 
帖子: 2
注册: 周一 7月 01, 2013 8:33 pm

Re: UVC摄像头驱动

帖子一般般_6133 » 周二 9月 10, 2013 8:35 pm

我把这段代码贴出来,大家帮我看看吧。我已经没招了:
int usb_video_io_read( resmgr_context_t *ctp, io_read_t *msg, RESMGR_OCB_T *ocb )
{
char temp=0;
int i;
int result;
int nleft;
int nbytes;
int nparts;
int status;
usb_video_t *usb_video;
struct usbd_urb *ctrl_urb;
uint32_t urb_status;
uint32_t data_len_in_trans;

if ((status = iofunc_read_verify (ctp, msg, ocb, NULL)) != EOK)
return (status);

if ((msg->i.xtype & _IO_XTYPE_MASK) != _IO_XTYPE_NONE)
return (ENOSYS);

fprintf(stderr,"ctrl urb point to 0x%x !\n",ctrl_urb);
ctrl_urb = usbd_alloc_urb(NULL);
fprintf(stderr,"ctrl urb point to 0x%x !\n",ctrl_urb);
if( !ctrl_urb ){
fprintf(stderr,"alloc ctrl urb failed with code %d !\n",errno);
return -1;
}

/*
* On all reads (first and subsequent), calculate
* how many bytes we can return to the client,
* based upon the number of bytes available (nleft)
* and the client's buffer size
*/

usb_video=TAILQ_FIRST(&(usb_video_ctrl.dlist));
fprintf(stderr,"usb_video point to 0x%x!\n",usb_video);


if(EOK ==( result=usbd_select_config(usb_video->device,1))){
fprintf(stderr,"-------------------------------------------\n");
fprintf(stderr,"selct config interface successfully !\n");
fprintf(stderr,"-------------------------------------------\n");
}else{
fprintf(stderr,"-------------------------------------------------\n");
fprintf(stderr,"selct config interface failed with code %d!\n",result);
fprintf(stderr,"-------------------------------------------------\n");
return -1;
}




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*start to the working interface of the systems*/

usbd_setup_vendor( ctrl_urb,
URB_DIR_OUT,
0x11,
USB_RECIPIENT_INTERFACE,
6,
0x01,
0,
0);

if( (status = usbd_io( ctrl_urb, usb_video->ep_cntl, NULL, usb_video, USBD_TIME_INFINITY )) ) {
fprintf(stderr,"probe set op with code %d return !\n",status);
return( status );
}



delay(1000);
if(usbd_urb_status(ctrl_urb, &urb_status, &data_len_in_trans) == EOK){
fprintf(stderr,"urb status after probe set is %d ,the length or transfer data is %d!\n",status,data_len_in_trans);
}else{
fprintf(stderr,"urb status acquire failed!\n");
}

usbd_setup_vendor( ctrl_urb,
URB_DIR_IN,
0x10,
USB_RECIPIENT_INTERFACE,
0,
0x01,
&temp,
0x1);

if(( status = usbd_io( ctrl_urb, usb_video->ep_cntl, NULL, usb_video, USBD_TIME_INFINITY )) ) {
fprintf(stderr,"probe get op with code %d return !\n",status);
return( status );
}


delay(1000);
fprintf(stderr,"afeter setting the current interface is %d !\n",temp);
if(usbd_urb_status( ctrl_urb, &urb_status, &data_len_in_trans) == EOK){
fprintf(stderr,"urb status after probe set is %d ,the length or transfer data is %d!\n",status,data_len_in_trans);
}else{
fprintf(stderr,"urb status acquire failed!\n");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// if(EOK ==( result=usbd_select_interface(usb_video->device,0,1))){
// fprintf(stderr,"-------------------------------------------\n");
// fprintf(stderr,"selct video stream interface successfully !\n");
// fprintf(stderr,"-------------------------------------------\n");
// }else{
// fprintf(stderr,"-------------------------------------------------\n");
// fprintf(stderr,"selct video stream interface failed with code %d!\n",result);
// fprintf(stderr,"-------------------------------------------------\n");
// return -1;
// }
//
// nleft = ocb->attr->nbytes - ocb->offset;
// nbytes = min (msg->i.nbytes, nleft);

if(EOK ==( result=usbd_setup_isochronous(usb_video->urb_isoch1 ,
URB_DIR_IN|URB_ISOCH_ASAP , NULL , usb_video->ep_isoch1_buf ,960 )))
{
fprintf(stderr,"-------------------------------------------\n");
fprintf(stderr,"get stream successfully!\n");
fprintf(stderr,"-------------------------------------------\n");
}

usbd_free_urb(ctrl_urb);
return( EOK );
}
一般般_6133
New Member
 
帖子: 2
注册: 周一 7月 01, 2013 8:33 pm


回到 四海同心QNX论坛

在线用户

正在浏览此版面的用户:Yahoo [Bot] 和 1 位游客

cron