Lines Matching refs:vs
314 #define video_stream_free_bufs(vs) \
315 video_stream_realloc_bufs((vs), 0)
1498 struct video_stream *vs = &sc->sc_stream_in;
1505 vs->vs_type = req->type;
1514 err = video_stream_setup_bufs(vs,
1521 buf = vs->vs_buf[i]->vb_buf;
1538 struct video_stream *vs = &sc->sc_stream_in;
1540 if (buf->type != vs->vs_type)
1542 if (buf->index >= vs->vs_nbufs)
1545 memcpy(buf, vs->vs_buf[buf->index]->vb_buf, sizeof(*buf));
1555 struct video_stream *vs = &sc->sc_stream_in;
1559 if (userbuf->type != vs->vs_type) {
1561 userbuf->type, vs->vs_type));
1564 if (userbuf->index >= vs->vs_nbufs) {
1566 userbuf->index, vs->vs_nbufs));
1570 switch (vs->vs_method) {
1578 mutex_enter(&vs->vs_lock);
1580 vb = vs->vs_buf[userbuf->index];
1585 mutex_exit(&vs->vs_lock);
1588 video_stream_enqueue(vs, vb);
1591 mutex_exit(&vs->vs_lock);
1605 struct video_stream *vs = &sc->sc_stream_in;
1609 if (buf->type != vs->vs_type) {
1612 buf->type, vs->vs_type);
1616 switch (vs->vs_method) {
1625 mutex_enter(&vs->vs_lock);
1627 if (vs->vs_flags & O_NONBLOCK) {
1628 vb = video_stream_dequeue(vs);
1630 mutex_exit(&vs->vs_lock);
1635 while ((vb = video_stream_dequeue(vs)) == NULL) {
1636 if (!vs->vs_streaming) {
1637 mutex_exit(&vs->vs_lock);
1640 err = cv_wait_sig(&vs->vs_sample_cv,
1641 &vs->vs_lock);
1643 mutex_exit(&vs->vs_lock);
1651 mutex_exit(&vs->vs_lock);
1655 vs->vs_method);
1666 struct video_stream *vs = &sc->sc_stream_in;
1669 if (vs->vs_streaming)
1671 if (type != vs->vs_type)
1683 vs->vs_streaming = true;
1691 struct video_stream *vs = &sc->sc_stream_in;
1694 if (!vs->vs_streaming)
1696 if (type != vs->vs_type)
1707 vs->vs_frameno = -1;
1708 vs->vs_sequence = 0;
1709 vs->vs_streaming = false;
1719 struct video_stream *vs;
1757 vs = &sc->sc_stream_in;
1760 err = hw->get_format(sc->hw_softc, &vs->vs_format);
1805 struct video_stream *vs;
1819 vs = &sc->sc_stream_in;
1822 if (vs->vs_method == VIDEO_STREAM_METHOD_NONE) {
1823 err = video_stream_setup_bufs(vs,
1829 err = video_stream_on(sc, vs->vs_type);
1832 } else if (vs->vs_method != VIDEO_STREAM_METHOD_READ) {
1836 mutex_enter(&vs->vs_lock);
1839 if (SIMPLEQ_EMPTY(&vs->vs_egress)) {
1840 if (vs->vs_flags & O_NONBLOCK) {
1841 mutex_exit(&vs->vs_lock);
1846 while (SIMPLEQ_EMPTY(&vs->vs_egress)) {
1847 err = cv_wait_sig(&vs->vs_sample_cv,
1848 &vs->vs_lock);
1850 mutex_exit(&vs->vs_lock);
1855 vb = SIMPLEQ_FIRST(&vs->vs_egress);
1857 vb = SIMPLEQ_FIRST(&vs->vs_egress);
1862 vb = video_stream_dequeue(vs);
1863 video_stream_enqueue(vs, vb);
1864 vs->vs_bytesread = 0;
1869 if (vs->vs_flags & O_NONBLOCK) {
1870 mutex_exit(&vs->vs_lock);
1875 err = cv_wait_sig(&vs->vs_sample_cv, &vs->vs_lock);
1877 mutex_exit(&vs->vs_lock);
1885 len = uimin(uio->uio_resid, vb->vb_buf->bytesused - vs->vs_bytesread);
1886 offset = vb->vb_buf->m.offset + vs->vs_bytesread;
1888 mutex_exit(&vs->vs_lock);
1891 if (scatter_io_init(&vs->vs_data, offset, len, &sio)) {
1902 mutex_enter(&vs->vs_lock);
1905 cv_signal(&vs->vs_sample_cv);
1907 vs->vs_bytesread += done;
1908 if (vs->vs_bytesread >= vb->vb_buf->bytesused) {
1909 vb = video_stream_dequeue(vs);
1910 video_stream_enqueue(vs, vb);
1911 vs->vs_bytesread = 0;
1914 mutex_exit(&vs->vs_lock);
2365 struct video_stream *vs;
2369 vs = &sc->sc_stream_in;
2375 if (vs->vs_method == VIDEO_STREAM_METHOD_NONE) {
2376 err = video_stream_setup_bufs(vs,
2382 err = video_stream_on(sc, vs->vs_type);
2387 mutex_enter(&vs->vs_lock);
2391 selrecord(l, &vs->vs_sel);
2392 mutex_exit(&vs->vs_lock);
2402 struct video_stream *vs;
2409 vs = &sc->sc_stream_in;
2411 return scatter_buf_map(&vs->vs_data, off);
2418 video_stream_init(struct video_stream *vs, const char *name)
2420 vs->vs_method = VIDEO_STREAM_METHOD_NONE;
2421 vs->vs_flags = 0;
2422 vs->vs_frameno = -1;
2423 vs->vs_sequence = 0;
2424 vs->vs_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2425 vs->vs_nbufs = 0;
2426 vs->vs_buf = NULL;
2427 vs->vs_streaming = false;
2429 memset(&vs->vs_format, 0, sizeof(vs->vs_format));
2431 SIMPLEQ_INIT(&vs->vs_ingress);
2432 SIMPLEQ_INIT(&vs->vs_egress);
2434 mutex_init(&vs->vs_lock, MUTEX_DEFAULT, IPL_NONE);
2435 cv_init(&vs->vs_sample_cv, name);
2436 selinit(&vs->vs_sel);
2438 scatter_buf_init(&vs->vs_data, name);
2442 video_stream_fini(struct video_stream *vs)
2445 /* while (SIMPLEQ_FIRST(&vs->vs_ingress) != NULL)
2446 SIMPLEQ_REMOVE_HEAD(&vs->vs_ingress, entries);
2447 while (SIMPLEQ_FIRST(&vs->vs_egress) != NULL)
2448 SIMPLEQ_REMOVE_HEAD(&vs->vs_egress, entries); */
2450 mutex_destroy(&vs->vs_lock);
2451 cv_destroy(&vs->vs_sample_cv);
2452 seldestroy(&vs->vs_sel);
2454 scatter_buf_destroy(&vs->vs_data);
2458 video_stream_setup_bufs(struct video_stream *vs,
2464 mutex_enter(&vs->vs_lock);
2468 for (i = 0; i < vs->vs_nbufs; ++i) {
2469 if (!(vs->vs_buf[i]->vb_buf->flags & V4L2_BUF_FLAG_QUEUED)) {
2470 mutex_exit(&vs->vs_lock);
2476 err = video_stream_realloc_bufs(vs, nbufs);
2478 mutex_exit(&vs->vs_lock);
2486 if (!(vs->vs_buf[i]->vb_buf->flags & V4L2_BUF_FLAG_QUEUED))
2487 video_stream_enqueue(vs, vs->vs_buf[i]);
2490 vs->vs_method = method;
2491 mutex_exit(&vs->vs_lock);
2501 video_stream_teardown_bufs(struct video_stream *vs)
2505 mutex_enter(&vs->vs_lock);
2507 if (vs->vs_streaming) {
2513 while (SIMPLEQ_FIRST(&vs->vs_ingress) != NULL)
2514 SIMPLEQ_REMOVE_HEAD(&vs->vs_ingress, entries);
2515 while (SIMPLEQ_FIRST(&vs->vs_egress) != NULL)
2516 SIMPLEQ_REMOVE_HEAD(&vs->vs_egress, entries);
2518 err = video_stream_free_bufs(vs);
2524 vs->vs_method = VIDEO_STREAM_METHOD_NONE;
2526 mutex_exit(&vs->vs_lock);
2560 video_stream_realloc_bufs(struct video_stream *vs, uint8_t nbufs)
2569 size = PAGE_ALIGN(vs->vs_format.sample_size) * nbufs;
2570 err = scatter_buf_set_size(&vs->vs_data, size);
2574 oldnbufs = vs->vs_nbufs;
2575 oldbuf = vs->vs_buf;
2577 vs->vs_nbufs = nbufs;
2579 vs->vs_buf =
2582 vs->vs_buf = NULL;
2585 minnbufs = uimin(vs->vs_nbufs, oldnbufs);
2588 vs->vs_buf[i] = oldbuf[i];
2590 for (; i < vs->vs_nbufs; ++i)
2591 vs->vs_buf[i] = video_buffer_alloc();
2604 for (i = 0; i < vs->vs_nbufs; ++i) {
2605 buf = vs->vs_buf[i]->vb_buf;
2607 buf->type = vs->vs_type;
2614 buf->length = PAGE_ALIGN(vs->vs_format.sample_size);
2627 video_stream_enqueue(struct video_stream *vs, struct video_buffer *vb)
2639 SIMPLEQ_INSERT_TAIL(&vs->vs_ingress, vb, entries);
2646 video_stream_dequeue(struct video_stream *vs)
2650 if (!SIMPLEQ_EMPTY(&vs->vs_egress)) {
2651 vb = SIMPLEQ_FIRST(&vs->vs_egress);
2652 SIMPLEQ_REMOVE_HEAD(&vs->vs_egress, entries);
2673 video_stream_write(struct video_stream *vs,
2680 mutex_enter(&vs->vs_lock);
2683 if (vs->vs_frameno >= 0 && vs->vs_frameno != payload->frameno)
2684 video_stream_sample_done(vs);
2686 vs->vs_frameno = payload->frameno;
2688 if (vs->vs_drop || SIMPLEQ_EMPTY(&vs->vs_ingress)) {
2690 vs->vs_sequence)); */
2691 vs->vs_drop = true;
2693 vb = SIMPLEQ_FIRST(&vs->vs_ingress);
2700 } else if (scatter_io_init(&vs->vs_data,
2719 video_stream_sample_done(vs);
2721 mutex_exit(&vs->vs_lock);
2729 video_stream_sample_done(struct video_stream *vs)
2733 if (vs->vs_drop) {
2734 vs->vs_drop = false;
2735 } else if (!SIMPLEQ_EMPTY(&vs->vs_ingress)) {
2736 vb = SIMPLEQ_FIRST(&vs->vs_ingress);
2737 vb->vb_buf->sequence = vs->vs_sequence;
2738 SIMPLEQ_REMOVE_HEAD(&vs->vs_ingress, entries);
2740 SIMPLEQ_INSERT_TAIL(&vs->vs_egress, vb, entries);
2741 cv_signal(&vs->vs_sample_cv);
2742 selnotify(&vs->vs_sel, 0, 0);
2747 vs->vs_frameno ^= 1;
2748 vs->vs_sequence++;
2755 video_stream_all_queued(struct video_stream *vs)