コード例 #1
0
ファイル: msm72k_udc.c プロジェクト: AndyLavr/kgdb-android
int usb_loop_poll_hw(struct usb_ep *_ept, int is_rx)
{
	struct msm_endpoint *act_ept, *ept = to_msm_endpoint(_ept);
	struct usb_info *ui = ept->ui;
	int done = 0;
	u32 n;

	/* Normally there is a read request in the endpoint, wait for new data */
	for (;;) {
		n = readl(USB_USBSTS);
		writel(n, USB_USBSTS);
		if (n & STS_UI) /* finished transaction */
			break;
	}

	/* USB Transaction is complete */
	if (n & STS_UI) {
		n = readl(USB_ENDPTSETUPSTAT);
		if (n & EPT_RX(0))
			handle_setup(ui);

		n = readl(USB_ENDPTCOMPLETE);
		writel(n, USB_ENDPTCOMPLETE);

		while (n) {
			unsigned bit = __ffs(n);
			act_ept = ui->ept + bit;
			if (ept == act_ept) {
				pr_debug("%s: recv'd right tx %d\n", __func__, bit);
				done = 1;
			}
			else {
				pr_debug("%s: recv'd extra tx from ept %d (exp %d)\n",
						__func__, bit, ept->bit);
			}
			/* always call the handler for KGDB and other usb functions. 
			 * this is to avoid hardware timeout, but can leave a bit 
			 * kernel code running when kgdb is invoked to stopped the 
			 * kernel. this works quite well with adb but might not 
			 * support usb mass storage devices very well.
			 */
			handle_endpoint(ui, bit);
			n = n & (~(1 << bit));
		}
	}

	return done ? 0 : -EAGAIN;
}
コード例 #2
0
ファイル: atu2.c プロジェクト: CANBus-Triple/open-usb-can
static int ep_setup(void)
{
	struct setup_request setup;

	BUG_ON(UEBCLX < 8);

	setup.bmRequestType = UEDATX;
	setup.bRequest = UEDATX;
	setup.wValue = usb_read_word();
	setup.wIndex = usb_read_word();
	setup.wLength = usb_read_word();

	if (!handle_setup(&setup))
		return 0;
	if (!(setup.bmRequestType & 0x80) && eps[0].state == EP_IDLE)
		usb_send(&eps[0], NULL, 0, NULL, NULL);
	return 1;
}
コード例 #3
0
ファイル: dcd_td243fc_rev2.c プロジェクト: bgtwoigu/1110
static void handle_ep0(td243fc_rev2_softc_t *sc, juint32_t ep_intr)
{
    DBG_V(DSLAVE_DCD, ("DCD: handle_ep0\n"));
    
    if(READ4(TD243FC_EPN_CONFIG_CONTROL_REG(0, 1)) & TD243FC_STL)
        dcd_stall_ep(sc->dev, NULL, 0);

    if (ep_intr & TD243FC_EP_BIT(0, 1))
    {
        handle_ep0_in_req(sc);
    }
    else 
    {
        if (READ4(TD243FC_EPN_CONFIG_CONTROL_REG(0, 0)) & TD243FC_SETUP_RECV)
            handle_setup(sc);
        else
            handle_ep0_out_req(sc);
    }
}
コード例 #4
0
static irqreturn_t usb_interrupt(int irq, void *data)
{
	struct usb_info *ui = data;
	unsigned n;

	n = readl(USB_USBSTS);
	writel(n, USB_USBSTS);

	/* somehow we got an IRQ while in the reset sequence: ignore it */
	if (ui->running == 0)
		return IRQ_HANDLED;

	if (n & STS_PCI) {
		switch (readl(USB_PORTSC) & PORTSC_PSPD_MASK) {
		case PORTSC_PSPD_FS:
			INFO("msm72k_udc: portchange USB_SPEED_FULL\n");
			ui->gadget.speed = USB_SPEED_FULL;
			break;
		case PORTSC_PSPD_LS:
			INFO("msm72k_udc: portchange USB_SPEED_LOW\n");
			ui->gadget.speed = USB_SPEED_LOW;
			break;
		case PORTSC_PSPD_HS:
			INFO("msm72k_udc: portchange USB_SPEED_HIGH\n");
			ui->gadget.speed = USB_SPEED_HIGH;
			break;
		}
	}

	if (n & STS_URI) {
		INFO("msm72k_udc: reset\n");

		writel(readl(USB_ENDPTSETUPSTAT), USB_ENDPTSETUPSTAT);
		writel(readl(USB_ENDPTCOMPLETE), USB_ENDPTCOMPLETE);
		writel(0xffffffff, USB_ENDPTFLUSH);
		writel(0, USB_ENDPTCTRL(1));

		if (ui->online != 0) {
			/* marking us offline will cause ept queue attempts
			** to fail
			*/
			ui->online = 0;

			flush_all_endpoints(ui);

			/* XXX: we can't seem to detect going offline,
			 * XXX:  so deconfigure on reset for the time being
			 */
			if (ui->driver) {
				printk(KERN_INFO "usb: notify offline\n");
				ui->driver->disconnect(&ui->gadget);
			}
		}
	}

	if (n & STS_SLI)
		INFO("msm72k_udc: suspend\n");

	if (n & STS_UI) {
		n = readl(USB_ENDPTSETUPSTAT);
		if (n & EPT_RX(0))
			handle_setup(ui);

		n = readl(USB_ENDPTCOMPLETE);
		writel(n, USB_ENDPTCOMPLETE);
		while (n) {
			unsigned bit = __ffs(n);
			handle_endpoint(ui, bit);
			n = n & (~(1 << bit));
		}
	}
	return IRQ_HANDLED;
}
コード例 #5
0
ファイル: usb.c プロジェクト: coreboot/chrome-ec
/* This handles both IN and OUT interrupts for EP0 */
static void ep0_interrupt(uint32_t intr_on_out, uint32_t intr_on_in)
{
	uint32_t doepint, diepint;
	enum table_case tc;
	int sr;

	/* Determine the interrupt cause and clear the bits quickly, but only
	 * if they really apply. I don't think they're trustworthy if we didn't
	 * actually get an interrupt. */
	doepint = GR_USB_DOEPINT(0);
	if (intr_on_out)
		GR_USB_DOEPINT(0) = doepint;
	diepint = GR_USB_DIEPINT(0);
	if (intr_on_in)
		GR_USB_DIEPINT(0) = diepint;

	print_later("doepint%c 0x%08x diepint%c 0x%08x what %d",
		    intr_on_out ? '!' : '_', doepint,
		    intr_on_in ? '!' : '_', diepint,
		    what_am_i_doing);

	/* Update current and pending RX FIFO buffers */
	if (intr_on_out && (doepint & DOEPINT_XFERCOMPL))
		got_RX_packet();

	/* Decode the situation according to Table 10-7 */
	tc = decode_table_10_7(doepint);
	sr = cur_out_desc->flags & DOEPDMA_SR;

	print_later("cur_out_idx %d flags 0x%08x case=%c SR=%d",
		    cur_out_idx, cur_out_desc->flags,
		    "0ABCDE67"[tc], !!sr, 0);

	switch (what_am_i_doing) {
	case WAITING_FOR_SETUP_PACKET:
		if (tc == TABLE_CASE_A || tc == TABLE_CASE_C) {
			if (sr) {
				handle_setup(tc);
			} else {
				report_error(tc);
				print_later("next_out_idx %d flags 0x%08x",
					    next_out_idx, next_out_desc->flags,
					    0, 0, 0);
				expect_setup_packet();
			}
		}
		/* This only happens if we're stalling, so keep doing it. */
		if (tc == TABLE_CASE_B) {
			print_later("Still waiting for Setup...",
				    0, 0, 0, 0, 0);
			stall_both_fifos();
		}
		break;

	case DATA_STAGE_IN:
		if (intr_on_in && (diepint & DIEPINT_XFERCOMPL)) {
			print_later("IN is complete? Maybe? How do we know?",
				    0, 0, 0, 0, 0);
			/* I don't *think* we need to do this, unless we need
			 * to transfer more data. Customer support agrees and
			 * it shouldn't matter if the host is well-behaved, but
			 * it seems like we had issues without it.
			 * TODO: Test this case until we know for sure. */
			GR_USB_DIEPCTL(0) = DXEPCTL_EPENA;

			/*
			 * The Programmer's Guide says (p291) to stall any
			 * further INs, but that's stupid because it'll destroy
			 * the packet we just transferred to SPRAM, so don't do
			 * that (we tried it anyway, and Bad Things happened).
			 * Also don't stop here, but keep looking at stuff.
			 */
		}

		/* But we should ignore the OUT endpoint if we didn't actually
		 * get an OUT interrupt. */
		if (!intr_on_out)
			break;

		if (tc == TABLE_CASE_B) {
			print_later("IN has been detected...", 0, 0, 0, 0, 0);
			/* The first IN packet has been seen. Keep going. */
			GR_USB_DIEPCTL(0) = DXEPCTL_CNAK | DXEPCTL_EPENA;
			GR_USB_DOEPCTL(0) = DXEPCTL_CNAK | DXEPCTL_EPENA;
			break;
		}
		if (tc == TABLE_CASE_A) {
			if (!sr) {
				/* We've handled the Status phase. All done. */
				print_later("Status phase complete",
					    0, 0, 0, 0, 0);
				expect_setup_packet();
				break;
			}
			/* We expected an OUT, but got a Setup. Deal with it. */
			print_later("Early Setup", 0, 0, 0, 0, 0);
			handle_setup(tc);
			break;
		}
		/* From the Exceptional Control Read Transfer section ... */
		if (tc == TABLE_CASE_C) {
			if (sr) {
				print_later("Early Setup w/Data packet seen",
					    0, 0, 0, 0, 0);
				handle_setup(tc);
				break;
			}
			print_later("Status phase complete. I think...",
				    0, 0, 0, 0, 0);
			expect_setup_packet();
			break;
		}

		/* Anything else should be ignorable. Right? */
		break;

	case NO_DATA_STAGE:
		if (intr_on_in && (diepint & DIEPINT_XFERCOMPL)) {
			print_later("IN descriptor processed", 0, 0, 0, 0, 0);
			/* Let the IN proceed */
			GR_USB_DIEPCTL(0) = DXEPCTL_EPENA;
		}

		/* Done unless we got an OUT interrupt */
		if (!intr_on_out)
			break;

		if (tc == TABLE_CASE_B) {
			print_later("IN has been detected...", 0, 0, 0, 0, 0);
			/* Let the IN proceed */
			GR_USB_DIEPCTL(0) = DXEPCTL_CNAK | DXEPCTL_EPENA;
			/* Reenable the previously prepared OUT descriptor. */
			GR_USB_DOEPCTL(0) = DXEPCTL_CNAK | DXEPCTL_EPENA;
			break;
		}

		if (tc == TABLE_CASE_A || tc == TABLE_CASE_C) {
			if (sr) {
				/* We expected an IN, but got a Setup. */
				print_later("Early Setup", 0, 0, 0, 0, 0);
				handle_setup(tc);
				break;
			}
		}

		/* Anything else means get ready for a Setup packet */
		print_later("Status phase complete. Maybe.",
			    0, 0, 0, 0, 0);
		expect_setup_packet();
		break;
	}
}
コード例 #6
0
ファイル: parser.c プロジェクト: itspjc/prj_threeguys
void parse_rtsp(){
	int str_len, cnt = 0;
	char *p, *q;
	char cmd[BUF_SIZE] = {0, };
	if((str_len = read(rtsp_sock, cmd, BUF_SIZE)) > 0){
		printf("-------------C -> S-------------\n"
			"%s\n", cmd);

		p = strtok(cmd, "\r\n");
		if (strstr(p,"OPTIONS") != NULL){
			rtspCmdType = RTSP_OPTIONS;
			p += 7;
		}else if (strstr(p,"DESCRIBE") != NULL){
			rtspCmdType = RTSP_DESCRIBE;
			p += 9;
		}else if (strstr(p,"SETUP") != NULL) {
			rtspCmdType = RTSP_SETUP;
			p += 6;
	   	}else if (strstr(p,"PLAY") != NULL) {
			rtspCmdType = RTSP_PLAY;
			p += 5;
   		}else if (strstr(p,"TEARDOWN") != NULL) {
			rtspCmdType = RTSP_TEARDOWN;
			p += 9;
		}else if(strstr(p, "PAUSE") != NULL){
			rtspCmdType = RTSP_PAUSE;
			p += 6;
		}else{
			printf("Command error\n");
			close(rtsp_sock);
			exit(-1);
		}
/*
		if(strstr(p, "rtsp://") != NULL && rtspCmdType == RTSP_OPTIONS)
        {
			p += 7;
			int i = 0;
			while(*p != '/')
				hostaddr[i++] = *(p++);
			hostaddr[i] = 0;

			i = 0;
			p++;
			while(*p != ' ')
				filename[i++] = *(p++);
			filename[i] = 0;
		}
        else
        {
			printf("URL error\n");
			close(rtsp_sock);
			exit(-1);
		}
*/
        hostaddr[0] = '1';
        hostaddr[1] = '9';
        hostaddr[2] = '2';
        hostaddr[3] = '.';
        hostaddr[4] = '1';
        hostaddr[5] = '6';
        hostaddr[6] = '8';
        hostaddr[7] = '.';
        hostaddr[8] = '5';
        hostaddr[9] = '6';
        hostaddr[10] = '.';
        hostaddr[11] = '1';
        hostaddr[12] = '0';
        hostaddr[13] = '2';
        hostaddr[14] = ':';
        hostaddr[15] = '3';
        hostaddr[16] = '0';
        hostaddr[17] = '0';
        hostaddr[18] = '5';
        hostaddr[19] = '\0';

        if(rtspCmdType == RTSP_OPTIONS)
        {
            char directive[32];
            char host[256];
            char version[32];
            char file_name[32];
            int pcnt;

            pcnt = sscanf(cmd, "%31s %255s %31s", directive, host, version);
            char *str_temp;
            str_temp = (char *) strrchr((char *)host, '/'); 
       
            file_name[0] = '.';
            file_name[1] = '.';
            file_name[2] = '/';
            file_name[3] = '.';
            file_name[4] = '.';
            file_name[5] = '/';
            file_name[6] = 'm';
            file_name[7] = 'e';
            file_name[8] = 'd';
            file_name[9] = 'i';
            file_name[10] = 'a';
            
            int i = 11;
            while(*str_temp != '\0')
            {
                file_name[i] = *(str_temp);
                
                if(i!=0)
                    filename[i-12]= *(str_temp);
                i++;
                str_temp++;
            }
            file_name[i] = '\0';
            filename[i-12]='\0';
            inputStream = fopen(file_name, "rb");
        }
		    
        p = strtok(NULL, "\r\n");
		
		if ((p = strstr(p, "CSeq")) != NULL)
        {
            p += 5;
			int i = 0;
			while(*p != 0)
			    cseq[i++] = *(p++);
			cseq[i] = 0;
		} 
        else
        {
            printf("CSeq error\n");
        }
		    

		if (rtspCmdType == RTSP_SETUP)
    	{
			p = strtok(NULL, "\r\n");
			p = strtok(NULL, "\r\n");
        	if ( strstr(p,"RTP/AVP/TCP") != NULL)
				transportMode = TCP;
			else
				transportMode = UDP;
			if((p = strstr(p, "client_port=")) != NULL){
				p += 12;
				int i = 0;
				char port[25] = {0, };
				while(*p != '-')
					port[i++] = *(p++);
				
				port[i] = 0;
				clientRTPPort = atoi(port);
				
				i = 0;
				p++;
				while(*p != 0){
					if(*p != '\r' || *p != '\n')
						port[i++] = *(p++);
				}
				port[i] = 0;
				clientRTCPPort = atoi(port);
			}	
		}
	}

/*	이게 이제 진짜로 읽을려고 해서, 이 부분도 fork로 따로 들어줘야 할 거 같음, 아니면 무한루프돔여기서 
 	if(streamer != NULL && streamer->rtcp_sock != 0)
    {
		while((str_len = read(streamer->rtcp_sock, cmd, BUF_SIZE)) > 0){
			printf("rtcp : %s\n", cmd);		
		}
	}
*/
	switch(rtspCmdType){
		case RTSP_OPTIONS : printf("option\n"); handle_option(); break;
		case RTSP_DESCRIBE : printf("describe\n"); handle_describe(); break;
		case RTSP_SETUP : printf("setup\n"); handle_setup(); break;
		case RTSP_PLAY : printf("play\n"); handle_play(); break;
		case RTSP_TEARDOWN : printf("teardown\n"); handle_teardown(); break;
		case RTSP_PAUSE : printf("pause\n"); handle_pause();break; 
		default : printf("Not implemented\n"); return;
	}
}