18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: DTV.fe 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _frontend_f_open: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci*************************** 78c2ecf20Sopenharmony_ciDigital TV frontend open() 88c2ecf20Sopenharmony_ci*************************** 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cife-open - Open a frontend device 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciSynopsis 168c2ecf20Sopenharmony_ci======== 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci.. code-block:: c 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci #include <fcntl.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci.. c:function:: int open( const char *device_name, int flags ) 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciArguments 258c2ecf20Sopenharmony_ci========= 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci``device_name`` 288c2ecf20Sopenharmony_ci Device to be opened. 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci``flags`` 318c2ecf20Sopenharmony_ci Open flags. Access can either be ``O_RDWR`` or ``O_RDONLY``. 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci Multiple opens are allowed with ``O_RDONLY``. In this mode, only 348c2ecf20Sopenharmony_ci query and read ioctls are allowed. 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci Only one open is allowed in ``O_RDWR``. In this mode, all ioctls are 378c2ecf20Sopenharmony_ci allowed. 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci When the ``O_NONBLOCK`` flag is given, the system calls may return 408c2ecf20Sopenharmony_ci ``EAGAIN`` error code when no data is available or when the device 418c2ecf20Sopenharmony_ci driver is temporarily busy. 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci Other flags have no effect. 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ciDescription 468c2ecf20Sopenharmony_ci=========== 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ciThis system call opens a named frontend device 498c2ecf20Sopenharmony_ci(``/dev/dvb/adapter?/frontend?``) for subsequent use. Usually the first 508c2ecf20Sopenharmony_cithing to do after a successful open is to find out the frontend type 518c2ecf20Sopenharmony_ciwith :ref:`FE_GET_INFO`. 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciThe device can be opened in read-only mode, which only allows monitoring 548c2ecf20Sopenharmony_ciof device status and statistics, or read/write mode, which allows any 558c2ecf20Sopenharmony_cikind of use (e.g. performing tuning operations.) 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciIn a system with multiple front-ends, it is usually the case that 588c2ecf20Sopenharmony_cimultiple devices cannot be open in read/write mode simultaneously. As 598c2ecf20Sopenharmony_cilong as a front-end device is opened in read/write mode, other open() 608c2ecf20Sopenharmony_cicalls in read/write mode will either fail or block, depending on whether 618c2ecf20Sopenharmony_cinon-blocking or blocking mode was specified. A front-end device opened 628c2ecf20Sopenharmony_ciin blocking mode can later be put into non-blocking mode (and vice 638c2ecf20Sopenharmony_civersa) using the F_SETFL command of the fcntl system call. This is a 648c2ecf20Sopenharmony_cistandard system call, documented in the Linux manual page for fcntl. 658c2ecf20Sopenharmony_ciWhen an open() call has succeeded, the device will be ready for use in 668c2ecf20Sopenharmony_cithe specified mode. This implies that the corresponding hardware is 678c2ecf20Sopenharmony_cipowered up, and that other front-ends may have been powered down to make 688c2ecf20Sopenharmony_cithat possible. 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ciReturn Value 718c2ecf20Sopenharmony_ci============ 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciOn success :c:func:`open()` returns the new file descriptor. 748c2ecf20Sopenharmony_ciOn error, -1 is returned, and the ``errno`` variable is set appropriately. 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ciPossible error codes are: 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciOn success 0 is returned, and :c:type:`ca_slot_info` is filled. 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ciOn error -1 is returned, and the ``errno`` variable is set 818c2ecf20Sopenharmony_ciappropriately. 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{2.5cm}|p{15.0cm}| 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci.. flat-table:: 868c2ecf20Sopenharmony_ci :header-rows: 0 878c2ecf20Sopenharmony_ci :stub-columns: 0 888c2ecf20Sopenharmony_ci :widths: 1 16 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci - - ``EPERM`` 918c2ecf20Sopenharmony_ci - The caller has no permission to access the device. 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci - - ``EBUSY`` 948c2ecf20Sopenharmony_ci - The the device driver is already in use. 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci - - ``EMFILE`` 978c2ecf20Sopenharmony_ci - The process already has the maximum number of files open. 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci - - ``ENFILE`` 1008c2ecf20Sopenharmony_ci - The limit on the total number of files open on the system has been 1018c2ecf20Sopenharmony_ci reached. 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ciThe generic error codes are described at the 1048c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 105