/* * omap_vout_vrfb.c * * Copyright (C) 2010 Texas Instruments. * * This file is licensed under the terms of the GNU General Public License * version 2. This program is licensed "as is" without any warranty of any * kind, whether express or implied. *
*/
/* * Function for allocating video buffers
*/ staticint omap_vout_allocate_vrfb_buffers(struct omap_vout_device *vout, unsignedint *count, int startindex)
{ int i, j;
for (i = 0; i < *count; i++) { if (!vout->smsshado_virt_addr[i]) {
vout->smsshado_virt_addr[i] =
omap_vout_alloc_buffer(vout->smsshado_size,
&vout->smsshado_phy_addr[i]);
} if (!vout->smsshado_virt_addr[i] && startindex != -1) { if (vout->vq.memory == V4L2_MEMORY_MMAP && i >= startindex) break;
} if (!vout->smsshado_virt_addr[i]) { for (j = 0; j < i; j++) {
omap_vout_free_buffer(
vout->smsshado_virt_addr[j],
vout->smsshado_size);
vout->smsshado_virt_addr[j] = 0;
vout->smsshado_phy_addr[j] = 0;
}
*count = 0; return -ENOMEM;
}
memset((void *)(long)vout->smsshado_virt_addr[i], 0,
vout->smsshado_size);
} return 0;
}
/* * Wakes up the application once the DMA transfer to VRFB space is completed.
*/ staticvoid omap_vout_vrfb_dma_tx_callback(void *data)
{ struct vid_vrfb_dma *t = (struct vid_vrfb_dma *) data;
if (vout->vrfb_dma_tx.req_status == DMA_CHAN_NOT_ALLOTED)
dev_info(&pdev->dev, ": failed to allocate DMA Channel for video%d\n",
vfd->minor);
init_waitqueue_head(&vout->vrfb_dma_tx.wait);
/* * statically allocated the VRFB buffer is done through * command line arguments
*/ if (static_vrfb_allocation) { if (omap_vout_allocate_vrfb_buffers(vout, &vrfb_num_bufs, -1)) {
ret = -ENOMEM; goto release_vrfb_ctx;
}
vout->vrfb_static_allocation = true;
} return 0;
/* * Allocate the buffers for the VRFB space. Data is copied from V4L2 * buffers to the VRFB buffers using the DMA engine.
*/ int omap_vout_vrfb_buffer_setup(struct omap_vout_device *vout, unsignedint *count, unsignedint startindex)
{ int i; bool yuv_mode;
if (!is_rotation_enabled(vout)) return 0;
/* If rotation is enabled, allocate memory for VRFB space also */
*count = *count > VRFB_NUM_BUFS ? VRFB_NUM_BUFS : *count;
/* Allocate the VRFB buffers only if the buffers are not * allocated during init time.
*/ if (!vout->vrfb_static_allocation) if (omap_vout_allocate_vrfb_buffers(vout, count, startindex)) return -ENOMEM;
for (i = 0; i < *count; i++)
omap_vrfb_setup(&vout->vrfb_context[i],
vout->smsshado_phy_addr[i], vout->pix.width,
vout->pix.height, vout->bpp, yuv_mode);
/* If rotation is enabled, copy input buffer into VRFB * memory space using DMA. We are copying input buffer * into VRFB memory space of desired angle and DSS will * read image VRFB memory for 0 degree angle
*/
status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
if (vout->vrfb_dma_tx.tx_status == 0) {
pr_err("%s: Timeout while waiting for DMA\n", __func__);
dmaengine_terminate_sync(chan); return -EINVAL;
} elseif (status != DMA_COMPLETE) {
pr_err("%s: DMA completion %s status\n", __func__,
status == DMA_ERROR ? "error" : "busy");
dmaengine_terminate_sync(chan); return -EINVAL;
}
/* Store buffers physical address into an array. Addresses
* from this array will be used to configure DSS */
rotation = calc_rotation(vout);
vout->queued_buf_addr[vb->index] =
vout->vrfb_context[vb->index].paddr[rotation]; return 0;
}
/* * Calculate the buffer offsets from which the streaming should * start. This offset calculation is mainly required because of * the VRFB 32 pixels alignment with rotation.
*/ void omap_vout_calculate_vrfb_offset(struct omap_vout_device *vout)
{ enum dss_rotation rotation; bool mirroring = vout->mirror; struct v4l2_rect *crop = &vout->crop; struct v4l2_pix_format *pix = &vout->pix; int *cropped_offset = &vout->cropped_offset; int vr_ps = 1, ps = 2, temp_ps = 2; int offset = 0, ctop = 0, cleft = 0, line_length = 0;
rotation = calc_rotation(vout);
if (V4L2_PIX_FMT_YUYV == pix->pixelformat ||
V4L2_PIX_FMT_UYVY == pix->pixelformat) { if (is_rotation_enabled(vout)) { /* * ps - Actual pixel size for YUYV/UYVY for * VRFB/Mirroring is 4 bytes * vr_ps - Virtually pixel size for YUYV/UYVY is * 2 bytes
*/
ps = 4;
vr_ps = 2;
} else {
ps = 2; /* otherwise the pixel size is 2 byte */
}
} elseif (V4L2_PIX_FMT_RGB32 == pix->pixelformat) {
ps = 4;
} elseif (V4L2_PIX_FMT_RGB24 == pix->pixelformat) {
ps = 3;
}
vout->ps = ps;
vout->vr_ps = vr_ps;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.