On Thu, Nov 24, 2011 at 11:12 AM, Amit Nagal <helloin.amit@xxxxxxxxx> wrote: >> > > (1 ) Hi , to test this , in one terminal , i continously read usb > audio interface ( /dev/dsp1) in a while loop , > and in another terminal , i reset the usb device via a userspace program . > At the time of reset , read(/dev/dsp1) failed with error : : Broken pipe . > > (2) Now , on linux machine , once read(/dev/dsp1) failed , i needed a > minimum of 150 ms delay before i can reopen > /dev/dsp1 successfully . if i donot provide this 150 ms delay , test > program fails to re-open /dev/dsp1 , > and in dmesg i could see a line 0:1:1: usb_set_interface failed . > Very Sorry , my mistake . As pointed in other mail , once read(/dev/dsp1) fails at usb reset , next open of /dev/dsp1 is success immediately . but the ioctl SNDCTL_DSP_CHANNELS keeps on failing with i/o error for about 110 ms . i enclose my userspace program log also below : ( len = data len read , i read 8k every time ) cnt=[58] len = 0x2000 8192 cnt=[59] len = 0x54 84 ==================read error=================: Broken pipe ========= CLOSING DEVICE========== file opened successfully ioctl : SNDCTL_DSP_CHANNELS - fail : Input/output error ......... ========= CLOSING DEVICE========== file opened successfully ioctl : SNDCTL_DSP_CHANNELS - success ioctl - SNDCTL_DSP_SPEED - success - temp=0xac44 ioctl - SNDCTL_DSP_SETFMT - success - temp = 0x10 cnt=[60] len = 0x2000 8192 cnt=[61] len = 0x2000 8192 2) here is userspace test program : #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <sys/soundcard.h> #include <sys/ioctl.h> int main(void) { int fd ; unsigned char buff[8192*2]; int buff_len , i ; int ret , temp ; unsigned int read_count = 0 ; ipod_retry : fd = open("/dev/dsp1" , O_RDWR); if(fd == -1) { printf("cannot open /dev/dsp \n"); goto ipod_retry ; } else { printf("file opened successfully\n"); } temp = 2 ; ret = ioctl(fd , SNDCTL_DSP_CHANNELS , &temp ); if(ret == -1 ) { perror("ioctl : SNDCTL_DSP_CHANNELS - fail\n"); goto close_ipod_fd ; } else { printf("ioctl : SNDCTL_DSP_CHANNELS - success \n"); } temp = 44100 ; ret = ioctl(fd , SNDCTL_DSP_SPEED , &temp ); if(ret == -1 ) { perror("ioctl : SNDCTL_DSP_SPEED - fail \n"); goto close_ipod_fd ; } else { printf("ioctl - SNDCTL_DSP_SPEED - success - temp=0x%x\n" , temp ); temp = AFMT_S16_LE ; ret = ioctl(fd , SNDCTL_DSP_SETFMT , &temp ); if(ret == -1 ) { perror("ioctl : SNDCTL_DSP_SETFMT - fail \n"); goto close_ipod_fd ; } else { printf("ioctl - SNDCTL_DSP_SETFMT - success - temp = 0x%x\n" , temp ); } } while(1) { buff_len = read(fd , buff , 8192 ) ; if(buff_len == -1 ){ perror("==================read error================="); goto close_ipod_fd ; } else{ printf("\ncnt=[%u] len = 0x%x %d\n\n" , ++read_count , buff_len , buff_len ); } } close_ipod_fd : printf("\n========= CLOSING DEVICE==========\n"); close(fd); goto ipod_retry ; return 0 ; } Thanx & Regards Amit Nagal -- 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