Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[sfrench/cifs-2.6.git] / Documentation / media / kapi / dtv-common.rst
1 Digital TV Common functions
2 ---------------------------
3
4 Math functions
5 ~~~~~~~~~~~~~~
6
7 Provide some commonly-used math functions, usually required in order to
8 estimate signal strength and signal to noise measurements in dB.
9
10 .. kernel-doc:: drivers/media/dvb-core/dvb_math.h
11
12
13 DVB devices
14 ~~~~~~~~~~~
15
16 Those functions are responsible for handling the DVB device nodes.
17
18 .. kernel-doc:: drivers/media/dvb-core/dvbdev.h
19
20 Digital TV Ring buffer
21 ~~~~~~~~~~~~~~~~~~~~~~
22
23 Those routines implement ring buffers used to handle digital TV data and
24 copy it from/to userspace.
25
26 .. note::
27
28   1) For performance reasons read and write routines don't check buffer sizes
29      and/or number of bytes free/available. This has to be done before these
30      routines are called. For example:
31
32    .. code-block:: c
33
34         /* write @buflen: bytes */
35         free = dvb_ringbuffer_free(rbuf);
36         if (free >= buflen)
37                 count = dvb_ringbuffer_write(rbuf, buffer, buflen);
38         else
39                 /* do something */
40
41         /* read min. 1000, max. @bufsize: bytes */
42         avail = dvb_ringbuffer_avail(rbuf);
43         if (avail >= 1000)
44                 count = dvb_ringbuffer_read(rbuf, buffer, min(avail, bufsize));
45         else
46                 /* do something */
47
48   2) If there is exactly one reader and one writer, there is no need
49      to lock read or write operations.
50      Two or more readers must be locked against each other.
51      Flushing the buffer counts as a read operation.
52      Resetting the buffer counts as a read and write operation.
53      Two or more writers must be locked against each other.
54
55 .. kernel-doc:: drivers/media/dvb-core/dvb_ringbuffer.h