frontend_f_open.rst 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2. .. c:namespace:: DTV.fe
  3. .. _frontend_f_open:
  4. ***************************
  5. Digital TV frontend open()
  6. ***************************
  7. Name
  8. ====
  9. fe-open - Open a frontend device
  10. Synopsis
  11. ========
  12. .. code-block:: c
  13. #include <fcntl.h>
  14. .. c:function:: int open( const char *device_name, int flags )
  15. Arguments
  16. =========
  17. ``device_name``
  18. Device to be opened.
  19. ``flags``
  20. Open flags. Access can either be ``O_RDWR`` or ``O_RDONLY``.
  21. Multiple opens are allowed with ``O_RDONLY``. In this mode, only
  22. query and read ioctls are allowed.
  23. Only one open is allowed in ``O_RDWR``. In this mode, all ioctls are
  24. allowed.
  25. When the ``O_NONBLOCK`` flag is given, the system calls may return
  26. ``EAGAIN`` error code when no data is available or when the device
  27. driver is temporarily busy.
  28. Other flags have no effect.
  29. Description
  30. ===========
  31. This system call opens a named frontend device
  32. (``/dev/dvb/adapter?/frontend?``) for subsequent use. Usually the first
  33. thing to do after a successful open is to find out the frontend type
  34. with :ref:`FE_GET_INFO`.
  35. The device can be opened in read-only mode, which only allows monitoring
  36. of device status and statistics, or read/write mode, which allows any
  37. kind of use (e.g. performing tuning operations.)
  38. In a system with multiple front-ends, it is usually the case that
  39. multiple devices cannot be open in read/write mode simultaneously. As
  40. long as a front-end device is opened in read/write mode, other open()
  41. calls in read/write mode will either fail or block, depending on whether
  42. non-blocking or blocking mode was specified. A front-end device opened
  43. in blocking mode can later be put into non-blocking mode (and vice
  44. versa) using the F_SETFL command of the fcntl system call. This is a
  45. standard system call, documented in the Linux manual page for fcntl.
  46. When an open() call has succeeded, the device will be ready for use in
  47. the specified mode. This implies that the corresponding hardware is
  48. powered up, and that other front-ends may have been powered down to make
  49. that possible.
  50. Return Value
  51. ============
  52. On success :c:func:`open()` returns the new file descriptor.
  53. On error, -1 is returned, and the ``errno`` variable is set appropriately.
  54. Possible error codes are:
  55. On success 0 is returned, and :c:type:`ca_slot_info` is filled.
  56. On error -1 is returned, and the ``errno`` variable is set
  57. appropriately.
  58. .. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
  59. .. flat-table::
  60. :header-rows: 0
  61. :stub-columns: 0
  62. :widths: 1 16
  63. - - ``EPERM``
  64. - The caller has no permission to access the device.
  65. - - ``EBUSY``
  66. - The device driver is already in use.
  67. - - ``EMFILE``
  68. - The process already has the maximum number of files open.
  69. - - ``ENFILE``
  70. - The limit on the total number of files open on the system has been
  71. reached.
  72. The generic error codes are described at the
  73. :ref:`Generic Error Codes <gen-errors>` chapter.