예제 #1
0
static int rtek_send_eth_frame( void *ctx, hsaddr_t buf, int len )
{
    rtek_softc_t *softc = (rtek_softc_t *) ctx;
    usbreq_t *ur;
    int txlen = len;
    unsigned char *txbuf;

    /* First some Realtek chip workarounds */
    if( txlen < 60 )		/* some strange limitation */
	txlen = 60;
    else if( !(txlen % 64) )	/* to handle module 64 packets */
	++txlen;

    txbuf = usb_dma_alloc(txlen);
    hs_memcpy_from_hs( txbuf, buf, txlen );

#if USBETH_DEBUG
    xprintf( "Outgoing packet :\n" );
    hexdump( txbuf, txlen, 16, txlen / 16 + 1 );
#endif
    ur = usb_make_request(softc->dev, softc->bulk_outpipe,
	                      txbuf, txlen, UR_FLAG_OUT);
    usb_sync_request(ur);
    usb_free_request(ur);
    usb_dma_free(txbuf);

    return( len );
}
예제 #2
0
static void rtek_queue_rx( rtek_softc_t *softc )
{
    softc->rx_ur = usb_make_request(softc->dev, softc->bulk_inpipe,
				    softc->rxbuf, sizeof(softc->rxbuf),
				    (UR_FLAG_IN | UR_FLAG_SHORTOK));
    usb_queue_request(softc->rx_ur);
}
예제 #3
0
int usbctrl_poll(usbctrl_softc_t * softc) {
    usbdev_t *dev = softc->dev;
    usbreq_t *ur;
    unsigned xdata_len = 0;

    uint8_t* buf = NULL;


    if (softc->is_wireless) 
    {
	uint8_t xdata[0xC] = { 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };//Request headset status command, works as a poll
        xdata_len = 0xC;
	
	buf = usb_dma_alloc(0xC);
    	if (buf == NULL) {
		printf("couldn't alloc buffer\n");
		/* Could not allocate a buffer, fail. */
		return -1;
	}
	memcpy(buf, &xdata, 0xC);
	
    }
    else 
    {
	return -1; //Polling not needed for wired controllers, and if there is a command it is not known at this time
    }

    ur = usb_make_request(dev, softc->uhid_ipipe_tx, buf, xdata_len, UR_FLAG_OUT);
    ur->ur_callback = usbctrl_set_led_callback;
    usb_queue_request(ur);

    return 0;
}
예제 #4
0
int usbctrl_set_leds(usbctrl_softc_t * softc, uint8_t clear) {
    usbdev_t *dev = softc->dev;
    usbreq_t *ur;

    //xenon_smc_set_led(1, (unsigned char) (0x80 >> 3)); //We need to figure out how to set ROL and still have the sync button work

    unsigned xdata_len = 0;
    int command;
    if(!clear)
    {
    command = 2 + (softc->index % 4);
    }
    else
    {
    command = 0;
    }
    
    uint8_t* buf = NULL;


    if (softc->is_wireless) 
    {
	uint8_t xdata[0xC] = { 0x00, 0x00, 0x08, 0x40 + (command % 0x0e), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        xdata_len = 0xC;
	
	buf = usb_dma_alloc(0xC);
    	if (buf == NULL) {
		printf("couldn't alloc buffer\n");
		/* Could not allocate a buffer, fail. */
		return -1;
	}

	memcpy(buf, &xdata, 0xC);
	
    }
    else 
    {
	uint8_t xdata[3] = { 0x01, 0x03, command };
        xdata_len = 3;

	buf = usb_dma_alloc(3);
    	if (buf == NULL) {
		printf("couldn't alloc buffer\n");
		/* Could not allocate a buffer, fail. */
		return -1;
	}

	memcpy(buf, &xdata, 3);
    }

    ur = usb_make_request(dev, softc->uhid_ipipe_tx, buf, xdata_len, UR_FLAG_OUT);
    ur->ur_callback = usbctrl_set_led_callback;
    usb_queue_request(ur);

    return 0;
}
예제 #5
0
static void usbhub_queue_intreq(usbdev_t *dev,usbhub_softc_t *softc)
{
    usbreq_t *ur;

    ur = usb_make_request(dev,
			  softc->uhub_ipipe,
			  softc->uhub_imsg,softc->uhub_ipipemps,
			  UR_FLAG_IN | UR_FLAG_SHORTOK);

    ur->ur_callback = usbhub_ireq_callback;

    usb_queue_request(ur);
}
예제 #6
0
static void usbctrl_queue_intreq(usbdev_t *dev,usbctrl_softc_t *softc)
{
	usbreq_t *ur;

	ur = usb_make_request(dev,
						  softc->uhid_ipipe,
						  softc->uhid_imsg, softc->uhid_ipipemps,
						  UR_FLAG_IN);

	ur->ur_callback = usbctrl_ireq_callback;

	ur->ur_ref = softc; //FIXME: Part of the hackish multi-wireless support

	usb_queue_request(ur);
}
예제 #7
0
int usbctrl_set_rumble(int port, uint8_t l, uint8_t r) {
    usbctrl_softc_t * softc = getcontroller(port);
    if(softc == NULL)
	return -1;
    usbdev_t *dev = softc->dev;
    usbreq_t *ur;
    unsigned xdata_len;
    uint8_t* buf = NULL;

    if(softc->is_wireless)
    {
	buf = usb_dma_alloc(0xC);

	if (buf == NULL) {
		printf("couldn't alloc buffer\n");
		/* Could not allocate a buffer, fail. */
		return -1;
	}

    	uint8_t xdata[0xC] = { 0x00, 0x01, 0x0f, 0xc0, 0x00, l, r, 0x00, 0x00, 0x00, 0x00, 0x00 };
	xdata_len = 0xC;
	memcpy(buf, &xdata, 0xC);
    }
    else
    {
	buf = usb_dma_alloc(0x8);
	 
	if (buf == NULL) {
		printf("couldn't alloc buffer\n");
		/* Could not allocate a buffer, fail. */
		return -1;
	}

	uint8_t xdata[0x8] = { 0x00, 0x08, 0x00, l, r, 0x00, 0x00, 0x00 };
	xdata_len = 0x8;
	memcpy(buf, &xdata, 0x8);
    }



    ur = usb_make_request(dev, softc->uhid_ipipe_tx, buf, xdata_len, UR_FLAG_OUT);
    ur->ur_callback = usbctrl_set_led_callback;
    usb_queue_request(ur);

    return 0;
}