Пример #1
0
/* LCD Output: 1 Descriptor -> 1 Framebuffer. */
static int lcd_output_desc_attach(struct jz_fb_win_info *win, void *mem)
{
	/* Get new descriptor. */
	struct jz_fb_dma_desc *desc = dma_desc_get(win);
	struct jz_fb_win_attr_info *a = &win->attr;

	D("Called.");

	if (!desc) {
		return -ENOMEM;
	}

	dma_desc_init(desc);

	/* Attach framebuffer to desciptors. */
	dma_desc_set_mem(desc, mem);
	dma_desc_set_data_size(desc, win->fb_frame_len);

	dma_desc_set_area_size(desc, a->w, a->h);
	
	dma_desc_add_to_chain(desc);

	dump_desc(desc);

	return 0;
}
Пример #2
0
static int lcd_output_desc_setup(struct jz_fb_win_info *win)
{
	struct jz_fb_panel_config *c = win->ctrl->ot->config;
	struct jz_fb_dma_desc *desc;
	
	D("Called.");	

	/* Setup DMA Palette Descriptor. */
	if (c->use_palette && win->index == 0) { /* Palette cannot be used on FG1. */
		unsigned long palette_size = 
			jz_fb_hw_bpp_to_palette_size(win->attr.bpp);

		D("Use Palette.");

		desc = dma_desc_get(win);
		if (!desc) {
			return -ENOMEM;
		}	

		dma_desc_init(desc);

		dma_desc_set_mem(desc, win->dma_palette);
		dma_desc_set_data_size(desc, palette_size);

		dma_desc_set_as_palette(desc);

		/* Set as DMA Descriptor Chain Head. */
		dma_desc_set_chain_head(desc);
		
		win->dma_desc_last_no_data = desc;
	}

	return 0;
}
static void reset_endpoints(int init)
{
    int i;

    /*
     * OUT EP 2 is an alias for OUT EP 0 on this HW!
     *
     * Resonates with "3 bidirectional- plus 1 in-endpoints in device mode"
     * from the datasheet, but why ep2 and not ep3?
     *
     * Reserve it here so we will skip over it in request_endpoint().
     */
    endpoints[2][1].state |= EP_STATE_ALLOCATED;

    for(i = 0; i < USB_NUM_EPS; i++) {
        /*
         * MPS sizes depending on speed:
         * LS: 8 (control), no bulk available
         * FS: 64 (control), 64 (bulk)
         * HS: 64 (control), 512 (bulk)
         *
         * We don't need to handle LS since there is no low-speed only
         * host AFAIK.
         */
        int mps = i == 0 ? 64 : (usb_drv_port_speed() ? 512 : 64);

        if (init) {
            if (endpoints[i][0].state & EP_STATE_BUSY) {
                if (endpoints[i][0].state & EP_STATE_ASYNC) {
                    endpoints[i][0].rc = -1;
                    semaphore_release(&endpoints[i][0].complete);
                } else {
                    usb_core_transfer_complete(i, USB_DIR_IN, -1, 0);
                }
            }
            endpoints[i][0].state = 0;
            semaphore_wait(&endpoints[i][0].complete, TIMEOUT_NOBLOCK);

            if (i != 2) { /* Skip the OUT EP0 alias */
                if (endpoints[i][1].state & EP_STATE_BUSY)
                    usb_core_transfer_complete(i, USB_DIR_OUT, -1, 0);
                endpoints[i][1].state = 0;
                semaphore_wait(&endpoints[i][1].complete, TIMEOUT_NOBLOCK);
                USB_OEP_SUP_PTR(i)    = 0;
            }
        }

        dma_desc_init(i, 0);
        USB_IEP_CTRL    (i) = USB_EP_CTRL_FLUSH|USB_EP_CTRL_SNAK;
        USB_IEP_MPS     (i) = mps; /* in bytes */
        /* We don't care about the 'IN token received' event */
        USB_IEP_STS_MASK(i) = USB_EP_STAT_IN; /* OF: 0x840 */
        USB_IEP_TXFSIZE (i) = mps/2; /* in dwords => mps*2 bytes */
        USB_IEP_STS     (i) = 0xffffffff; /* clear status */
        USB_IEP_DESC_PTR(i) = 0;

        if (i != 2) { /* Skip the OUT EP0 alias */
            dma_desc_init(i, 1);
            USB_OEP_CTRL    (i) = USB_EP_CTRL_FLUSH|USB_EP_CTRL_SNAK;
            USB_OEP_MPS     (i) = (mps/2 << 16) | mps;
            USB_OEP_STS_MASK(i) = USB_EP_STAT_BNA; /* OF: 0x1800 */
            USB_OEP_RXFR    (i) = 0;      /* Always 0 in OF trace? */
            USB_OEP_STS     (i) = 0xffffffff; /* clear status */
            USB_OEP_DESC_PTR(i) = 0;
        }
    }

    setup_desc_init(setup_desc);
    USB_OEP_SUP_PTR(0)    = AS3525_PHYSICAL_ADDR((int)setup_desc);
}