Lines Matching refs:vs
313 #define video_stream_free_bufs(vs) \ argument
314 video_stream_realloc_bufs((vs), 0)
1488 struct video_stream *vs = &sc->sc_stream_in; in video_request_bufs() local
1495 vs->vs_type = req->type; in video_request_bufs()
1504 err = video_stream_setup_bufs(vs, in video_request_bufs()
1511 buf = vs->vs_buf[i]->vb_buf; in video_request_bufs()
1528 struct video_stream *vs = &sc->sc_stream_in; in video_query_buf() local
1530 if (buf->type != vs->vs_type) in video_query_buf()
1532 if (buf->index >= vs->vs_nbufs) in video_query_buf()
1535 memcpy(buf, vs->vs_buf[buf->index]->vb_buf, sizeof(*buf)); in video_query_buf()
1545 struct video_stream *vs = &sc->sc_stream_in; in video_queue_buf() local
1549 if (userbuf->type != vs->vs_type) { in video_queue_buf()
1551 userbuf->type, vs->vs_type)); in video_queue_buf()
1554 if (userbuf->index >= vs->vs_nbufs) { in video_queue_buf()
1556 userbuf->index, vs->vs_nbufs)); in video_queue_buf()
1560 switch (vs->vs_method) { in video_queue_buf()
1568 mutex_enter(&vs->vs_lock); in video_queue_buf()
1570 vb = vs->vs_buf[userbuf->index]; in video_queue_buf()
1575 mutex_exit(&vs->vs_lock); in video_queue_buf()
1578 video_stream_enqueue(vs, vb); in video_queue_buf()
1581 mutex_exit(&vs->vs_lock); in video_queue_buf()
1595 struct video_stream *vs = &sc->sc_stream_in; in video_dequeue_buf() local
1599 if (buf->type != vs->vs_type) { in video_dequeue_buf()
1602 buf->type, vs->vs_type); in video_dequeue_buf()
1606 switch (vs->vs_method) { in video_dequeue_buf()
1615 mutex_enter(&vs->vs_lock); in video_dequeue_buf()
1617 if (vs->vs_flags & O_NONBLOCK) { in video_dequeue_buf()
1618 vb = video_stream_dequeue(vs); in video_dequeue_buf()
1620 mutex_exit(&vs->vs_lock); in video_dequeue_buf()
1625 while ((vb = video_stream_dequeue(vs)) == NULL) { in video_dequeue_buf()
1626 if (!vs->vs_streaming) { in video_dequeue_buf()
1627 mutex_exit(&vs->vs_lock); in video_dequeue_buf()
1630 err = cv_wait_sig(&vs->vs_sample_cv, in video_dequeue_buf()
1631 &vs->vs_lock); in video_dequeue_buf()
1633 mutex_exit(&vs->vs_lock); in video_dequeue_buf()
1641 mutex_exit(&vs->vs_lock); in video_dequeue_buf()
1645 vs->vs_method); in video_dequeue_buf()
1656 struct video_stream *vs = &sc->sc_stream_in; in video_stream_on() local
1659 if (vs->vs_streaming) in video_stream_on()
1661 if (type != vs->vs_type) in video_stream_on()
1673 vs->vs_streaming = true; in video_stream_on()
1681 struct video_stream *vs = &sc->sc_stream_in; in video_stream_off() local
1684 if (!vs->vs_streaming) in video_stream_off()
1686 if (type != vs->vs_type) in video_stream_off()
1697 vs->vs_frameno = -1; in video_stream_off()
1698 vs->vs_sequence = 0; in video_stream_off()
1699 vs->vs_streaming = false; in video_stream_off()
1709 struct video_stream *vs; in videoopen() local
1747 vs = &sc->sc_stream_in; in videoopen()
1750 err = hw->get_format(sc->hw_softc, &vs->vs_format); in videoopen()
1795 struct video_stream *vs; in videoread() local
1809 vs = &sc->sc_stream_in; in videoread()
1812 if (vs->vs_method == VIDEO_STREAM_METHOD_NONE) { in videoread()
1813 err = video_stream_setup_bufs(vs, in videoread()
1819 err = video_stream_on(sc, vs->vs_type); in videoread()
1822 } else if (vs->vs_method != VIDEO_STREAM_METHOD_READ) { in videoread()
1826 mutex_enter(&vs->vs_lock); in videoread()
1829 if (SIMPLEQ_EMPTY(&vs->vs_egress)) { in videoread()
1830 if (vs->vs_flags & O_NONBLOCK) { in videoread()
1831 mutex_exit(&vs->vs_lock); in videoread()
1836 while (SIMPLEQ_EMPTY(&vs->vs_egress)) { in videoread()
1837 err = cv_wait_sig(&vs->vs_sample_cv, in videoread()
1838 &vs->vs_lock); in videoread()
1840 mutex_exit(&vs->vs_lock); in videoread()
1845 vb = SIMPLEQ_FIRST(&vs->vs_egress); in videoread()
1847 vb = SIMPLEQ_FIRST(&vs->vs_egress); in videoread()
1852 vb = video_stream_dequeue(vs); in videoread()
1853 video_stream_enqueue(vs, vb); in videoread()
1854 vs->vs_bytesread = 0; in videoread()
1858 mutex_exit(&vs->vs_lock); in videoread()
1860 len = uimin(uio->uio_resid, vb->vb_buf->bytesused - vs->vs_bytesread); in videoread()
1861 offset = vb->vb_buf->m.offset + vs->vs_bytesread; in videoread()
1863 if (scatter_io_init(&vs->vs_data, offset, len, &sio)) { in videoread()
1867 vs->vs_bytesread += (len - sio.sio_resid); in videoread()
1874 if (vs->vs_bytesread >= vb->vb_buf->bytesused) { in videoread()
1875 mutex_enter(&vs->vs_lock); in videoread()
1876 vb = video_stream_dequeue(vs); in videoread()
1877 video_stream_enqueue(vs, vb); in videoread()
1878 mutex_exit(&vs->vs_lock); in videoread()
1880 vs->vs_bytesread = 0; in videoread()
2332 struct video_stream *vs; in videopoll() local
2336 vs = &sc->sc_stream_in; in videopoll()
2342 if (vs->vs_method == VIDEO_STREAM_METHOD_NONE) { in videopoll()
2343 err = video_stream_setup_bufs(vs, in videopoll()
2349 err = video_stream_on(sc, vs->vs_type); in videopoll()
2354 mutex_enter(&vs->vs_lock); in videopoll()
2358 selrecord(l, &vs->vs_sel); in videopoll()
2359 mutex_exit(&vs->vs_lock); in videopoll()
2369 struct video_stream *vs; in videommap() local
2376 vs = &sc->sc_stream_in; in videommap()
2378 return scatter_buf_map(&vs->vs_data, off); in videommap()
2385 video_stream_init(struct video_stream *vs) in video_stream_init() argument
2387 vs->vs_method = VIDEO_STREAM_METHOD_NONE; in video_stream_init()
2388 vs->vs_flags = 0; in video_stream_init()
2389 vs->vs_frameno = -1; in video_stream_init()
2390 vs->vs_sequence = 0; in video_stream_init()
2391 vs->vs_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in video_stream_init()
2392 vs->vs_nbufs = 0; in video_stream_init()
2393 vs->vs_buf = NULL; in video_stream_init()
2394 vs->vs_streaming = false; in video_stream_init()
2396 memset(&vs->vs_format, 0, sizeof(vs->vs_format)); in video_stream_init()
2398 SIMPLEQ_INIT(&vs->vs_ingress); in video_stream_init()
2399 SIMPLEQ_INIT(&vs->vs_egress); in video_stream_init()
2401 mutex_init(&vs->vs_lock, MUTEX_DEFAULT, IPL_NONE); in video_stream_init()
2402 cv_init(&vs->vs_sample_cv, "video"); in video_stream_init()
2403 selinit(&vs->vs_sel); in video_stream_init()
2405 scatter_buf_init(&vs->vs_data); in video_stream_init()
2409 video_stream_fini(struct video_stream *vs) in video_stream_fini() argument
2417 mutex_destroy(&vs->vs_lock); in video_stream_fini()
2418 cv_destroy(&vs->vs_sample_cv); in video_stream_fini()
2419 seldestroy(&vs->vs_sel); in video_stream_fini()
2421 scatter_buf_destroy(&vs->vs_data); in video_stream_fini()
2425 video_stream_setup_bufs(struct video_stream *vs, in video_stream_setup_bufs() argument
2431 mutex_enter(&vs->vs_lock); in video_stream_setup_bufs()
2435 for (i = 0; i < vs->vs_nbufs; ++i) { in video_stream_setup_bufs()
2436 if (!(vs->vs_buf[i]->vb_buf->flags & V4L2_BUF_FLAG_QUEUED)) { in video_stream_setup_bufs()
2437 mutex_exit(&vs->vs_lock); in video_stream_setup_bufs()
2443 err = video_stream_realloc_bufs(vs, nbufs); in video_stream_setup_bufs()
2445 mutex_exit(&vs->vs_lock); in video_stream_setup_bufs()
2453 if (!(vs->vs_buf[i]->vb_buf->flags & V4L2_BUF_FLAG_QUEUED)) in video_stream_setup_bufs()
2454 video_stream_enqueue(vs, vs->vs_buf[i]); in video_stream_setup_bufs()
2457 vs->vs_method = method; in video_stream_setup_bufs()
2458 mutex_exit(&vs->vs_lock); in video_stream_setup_bufs()
2468 video_stream_teardown_bufs(struct video_stream *vs) in video_stream_teardown_bufs() argument
2472 mutex_enter(&vs->vs_lock); in video_stream_teardown_bufs()
2474 if (vs->vs_streaming) { in video_stream_teardown_bufs()
2480 while (SIMPLEQ_FIRST(&vs->vs_ingress) != NULL) in video_stream_teardown_bufs()
2481 SIMPLEQ_REMOVE_HEAD(&vs->vs_ingress, entries); in video_stream_teardown_bufs()
2482 while (SIMPLEQ_FIRST(&vs->vs_egress) != NULL) in video_stream_teardown_bufs()
2483 SIMPLEQ_REMOVE_HEAD(&vs->vs_egress, entries); in video_stream_teardown_bufs()
2485 err = video_stream_free_bufs(vs); in video_stream_teardown_bufs()
2491 vs->vs_method = VIDEO_STREAM_METHOD_NONE; in video_stream_teardown_bufs()
2493 mutex_exit(&vs->vs_lock); in video_stream_teardown_bufs()
2527 video_stream_realloc_bufs(struct video_stream *vs, uint8_t nbufs) in video_stream_realloc_bufs() argument
2536 size = PAGE_ALIGN(vs->vs_format.sample_size) * nbufs; in video_stream_realloc_bufs()
2537 err = scatter_buf_set_size(&vs->vs_data, size); in video_stream_realloc_bufs()
2541 oldnbufs = vs->vs_nbufs; in video_stream_realloc_bufs()
2542 oldbuf = vs->vs_buf; in video_stream_realloc_bufs()
2544 vs->vs_nbufs = nbufs; in video_stream_realloc_bufs()
2546 vs->vs_buf = in video_stream_realloc_bufs()
2549 vs->vs_buf = NULL; in video_stream_realloc_bufs()
2552 minnbufs = uimin(vs->vs_nbufs, oldnbufs); in video_stream_realloc_bufs()
2555 vs->vs_buf[i] = oldbuf[i]; in video_stream_realloc_bufs()
2557 for (; i < vs->vs_nbufs; ++i) in video_stream_realloc_bufs()
2558 vs->vs_buf[i] = video_buffer_alloc(); in video_stream_realloc_bufs()
2571 for (i = 0; i < vs->vs_nbufs; ++i) { in video_stream_realloc_bufs()
2572 buf = vs->vs_buf[i]->vb_buf; in video_stream_realloc_bufs()
2574 buf->type = vs->vs_type; in video_stream_realloc_bufs()
2581 buf->length = PAGE_ALIGN(vs->vs_format.sample_size); in video_stream_realloc_bufs()
2594 video_stream_enqueue(struct video_stream *vs, struct video_buffer *vb) in video_stream_enqueue() argument
2606 SIMPLEQ_INSERT_TAIL(&vs->vs_ingress, vb, entries); in video_stream_enqueue()
2613 video_stream_dequeue(struct video_stream *vs) in video_stream_dequeue() argument
2617 if (!SIMPLEQ_EMPTY(&vs->vs_egress)) { in video_stream_dequeue()
2618 vb = SIMPLEQ_FIRST(&vs->vs_egress); in video_stream_dequeue()
2619 SIMPLEQ_REMOVE_HEAD(&vs->vs_egress, entries); in video_stream_dequeue()
2640 video_stream_write(struct video_stream *vs, in video_stream_write() argument
2647 mutex_enter(&vs->vs_lock); in video_stream_write()
2650 if (vs->vs_frameno >= 0 && vs->vs_frameno != payload->frameno) in video_stream_write()
2651 video_stream_sample_done(vs); in video_stream_write()
2653 vs->vs_frameno = payload->frameno; in video_stream_write()
2655 if (vs->vs_drop || SIMPLEQ_EMPTY(&vs->vs_ingress)) { in video_stream_write()
2658 vs->vs_drop = true; in video_stream_write()
2660 vb = SIMPLEQ_FIRST(&vs->vs_ingress); in video_stream_write()
2667 } else if (scatter_io_init(&vs->vs_data, in video_stream_write()
2686 video_stream_sample_done(vs); in video_stream_write()
2688 mutex_exit(&vs->vs_lock); in video_stream_write()
2696 video_stream_sample_done(struct video_stream *vs) in video_stream_sample_done() argument
2700 if (vs->vs_drop) { in video_stream_sample_done()
2701 vs->vs_drop = false; in video_stream_sample_done()
2702 } else if (!SIMPLEQ_EMPTY(&vs->vs_ingress)) { in video_stream_sample_done()
2703 vb = SIMPLEQ_FIRST(&vs->vs_ingress); in video_stream_sample_done()
2704 vb->vb_buf->sequence = vs->vs_sequence; in video_stream_sample_done()
2705 SIMPLEQ_REMOVE_HEAD(&vs->vs_ingress, entries); in video_stream_sample_done()
2707 SIMPLEQ_INSERT_TAIL(&vs->vs_egress, vb, entries); in video_stream_sample_done()
2708 cv_signal(&vs->vs_sample_cv); in video_stream_sample_done()
2709 selnotify(&vs->vs_sel, 0, 0); in video_stream_sample_done()
2714 vs->vs_frameno ^= 1; in video_stream_sample_done()
2715 vs->vs_sequence++; in video_stream_sample_done()