dtv-common.rst 1.5 KB

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