struct buffer * disp_get_vid_buffer(struct display *disp) { struct buffer *buf = NULL; if (!list_is_empty(&disp->unlocked)) { buf = list_last_entry(&disp->unlocked, struct buffer, unlocked); list_del(&buf->unlocked); /* barrier.. if we are using GPU blitting, we need to make sure * that the GPU is finished: */ omap_bo_cpu_prep(buf->bo[0], OMAP_GEM_WRITE); omap_bo_cpu_fini(buf->bo[0], OMAP_GEM_WRITE); }
void * capture_loop(void *arg) { struct thr_data *data = (struct thr_data *)arg; struct display *disp = data->disp; struct v4l2 *v4l2 = data->v4l2; uint32_t fourcc = data->fourcc; uint32_t width = data->width, height = data->height; struct buffer **buffers, *capt, *alg, **alg_bufs; int ret, i; int *src, *dst; int w, h; buffers = disp_get_vid_buffers(disp, NBUF, fourcc, width, height); if (!buffers) { return NULL; } alg_bufs = disp_get_vid_buffers(disp, 1, fourcc, width, height); alg = alg_bufs[0]; ret = v4l2_reqbufs(v4l2, buffers, NBUF); if (ret) { return NULL; } for (i = 0; i < NBUF; i++) { v4l2_qbuf(v4l2, buffers[i]); } ret = v4l2_streamon(v4l2); if (ret) { return NULL; } for (i = 1; i < CNT; i++) { capt = v4l2_dqbuf(v4l2); src = omap_bo_map(capt->bo[0]); dst = omap_bo_map(alg->bo[0]); //printf("debug: %p %p\n", src, dst); omap_bo_cpu_prep(capt->bo[0], OMAP_GEM_READ); omap_bo_cpu_prep(alg->bo[0], OMAP_GEM_WRITE); //printf("bufers prepared\n"); /* for (h=0; h<720; h++) for(w=0;w<1280 / 2;w++) dst[h * 1280 / 2 + w] = src[h * 1280 / 2 + 1280 / 2 - w]; */ printf("Calling get Image"); //getImage(dst); //printf("Mirrrored\n"); omap_bo_cpu_fini(capt->bo[0], OMAP_GEM_READ); omap_bo_cpu_fini(alg->bo[0], OMAP_GEM_WRITE); ret = disp_post_vid_buffer(disp, alg, 0, 0, width, height); //printf("Alg buffer posted\n"); ret = disp_post_vid_buffer(disp, capt, 0, 0, width, height); if (ret) { ERROR("Post buffer failed"); return NULL; } v4l2_qbuf(v4l2, capt); } v4l2_streamoff(v4l2); MSG("Ok!"); return disp; }