xref: /openbmc/linux/Documentation/driver-api/media/dtv-common.rst (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
1*ff768f59SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0
2*ff768f59SMauro Carvalho Chehab
3*ff768f59SMauro Carvalho ChehabDigital TV Common functions
4*ff768f59SMauro Carvalho Chehab---------------------------
5*ff768f59SMauro Carvalho Chehab
6*ff768f59SMauro Carvalho ChehabDVB devices
7*ff768f59SMauro Carvalho Chehab~~~~~~~~~~~
8*ff768f59SMauro Carvalho Chehab
9*ff768f59SMauro Carvalho ChehabThose functions are responsible for handling the DVB device nodes.
10*ff768f59SMauro Carvalho Chehab
11*ff768f59SMauro Carvalho Chehab.. kernel-doc:: include/media/dvbdev.h
12*ff768f59SMauro Carvalho Chehab
13*ff768f59SMauro Carvalho ChehabDigital TV Ring buffer
14*ff768f59SMauro Carvalho Chehab~~~~~~~~~~~~~~~~~~~~~~
15*ff768f59SMauro Carvalho Chehab
16*ff768f59SMauro Carvalho ChehabThose routines implement ring buffers used to handle digital TV data and
17*ff768f59SMauro Carvalho Chehabcopy it from/to userspace.
18*ff768f59SMauro Carvalho Chehab
19*ff768f59SMauro Carvalho Chehab.. note::
20*ff768f59SMauro Carvalho Chehab
21*ff768f59SMauro Carvalho Chehab  1) For performance reasons read and write routines don't check buffer sizes
22*ff768f59SMauro Carvalho Chehab     and/or number of bytes free/available. This has to be done before these
23*ff768f59SMauro Carvalho Chehab     routines are called. For example:
24*ff768f59SMauro Carvalho Chehab
25*ff768f59SMauro Carvalho Chehab   .. code-block:: c
26*ff768f59SMauro Carvalho Chehab
27*ff768f59SMauro Carvalho Chehab        /* write @buflen: bytes */
28*ff768f59SMauro Carvalho Chehab        free = dvb_ringbuffer_free(rbuf);
29*ff768f59SMauro Carvalho Chehab        if (free >= buflen)
30*ff768f59SMauro Carvalho Chehab                count = dvb_ringbuffer_write(rbuf, buffer, buflen);
31*ff768f59SMauro Carvalho Chehab        else
32*ff768f59SMauro Carvalho Chehab                /* do something */
33*ff768f59SMauro Carvalho Chehab
34*ff768f59SMauro Carvalho Chehab        /* read min. 1000, max. @bufsize: bytes */
35*ff768f59SMauro Carvalho Chehab        avail = dvb_ringbuffer_avail(rbuf);
36*ff768f59SMauro Carvalho Chehab        if (avail >= 1000)
37*ff768f59SMauro Carvalho Chehab                count = dvb_ringbuffer_read(rbuf, buffer, min(avail, bufsize));
38*ff768f59SMauro Carvalho Chehab        else
39*ff768f59SMauro Carvalho Chehab                /* do something */
40*ff768f59SMauro Carvalho Chehab
41*ff768f59SMauro Carvalho Chehab  2) If there is exactly one reader and one writer, there is no need
42*ff768f59SMauro Carvalho Chehab     to lock read or write operations.
43*ff768f59SMauro Carvalho Chehab     Two or more readers must be locked against each other.
44*ff768f59SMauro Carvalho Chehab     Flushing the buffer counts as a read operation.
45*ff768f59SMauro Carvalho Chehab     Resetting the buffer counts as a read and write operation.
46*ff768f59SMauro Carvalho Chehab     Two or more writers must be locked against each other.
47*ff768f59SMauro Carvalho Chehab
48*ff768f59SMauro Carvalho Chehab.. kernel-doc:: include/media/dvb_ringbuffer.h
49*ff768f59SMauro Carvalho Chehab
50*ff768f59SMauro Carvalho ChehabDigital TV VB2 handler
51*ff768f59SMauro Carvalho Chehab~~~~~~~~~~~~~~~~~~~~~~
52*ff768f59SMauro Carvalho Chehab
53*ff768f59SMauro Carvalho Chehab.. kernel-doc:: include/media/dvb_vb2.h
54