Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 1 | .. -*- coding: utf-8; mode: rst -*- |
| 2 | |
| 3 | .. _frontend_f_open: |
| 4 | |
| 5 | ******************* |
| 6 | DVB frontend open() |
| 7 | ******************* |
| 8 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 9 | Name |
Mauro Carvalho Chehab | 586027c | 2016-07-05 07:58:48 -0300 | [diff] [blame] | 10 | ==== |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 11 | |
Mauro Carvalho Chehab | 586027c | 2016-07-05 07:58:48 -0300 | [diff] [blame] | 12 | fe-open - Open a frontend device |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 13 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 14 | |
| 15 | Synopsis |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 16 | ======== |
| 17 | |
| 18 | .. code-block:: c |
| 19 | |
| 20 | #include <fcntl.h> |
| 21 | |
| 22 | |
Mauro Carvalho Chehab | b7e67f6 | 2016-07-02 09:49:16 -0300 | [diff] [blame] | 23 | .. cpp:function:: int open( const char *device_name, int flags ) |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 24 | |
Mauro Carvalho Chehab | 586027c | 2016-07-05 07:58:48 -0300 | [diff] [blame] | 25 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 26 | Arguments |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 27 | ========= |
| 28 | |
| 29 | ``device_name`` |
| 30 | Device to be opened. |
| 31 | |
| 32 | ``flags`` |
| 33 | Open flags. Access can either be ``O_RDWR`` or ``O_RDONLY``. |
| 34 | |
| 35 | Multiple opens are allowed with ``O_RDONLY``. In this mode, only |
| 36 | query and read ioctls are allowed. |
| 37 | |
| 38 | Only one open is allowed in ``O_RDWR``. In this mode, all ioctls are |
| 39 | allowed. |
| 40 | |
| 41 | When the ``O_NONBLOCK`` flag is given, the system calls may return |
Mauro Carvalho Chehab | cdb4af0 | 2016-07-03 11:53:09 -0300 | [diff] [blame] | 42 | ``EAGAIN`` error code when no data is available or when the device |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 43 | driver is temporarily busy. |
| 44 | |
| 45 | Other flags have no effect. |
| 46 | |
| 47 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 48 | Description |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 49 | =========== |
| 50 | |
| 51 | This system call opens a named frontend device |
| 52 | (``/dev/dvb/adapter?/frontend?``) for subsequent use. Usually the first |
| 53 | thing to do after a successful open is to find out the frontend type |
Mauro Carvalho Chehab | 7347081 | 2016-07-01 13:58:44 -0300 | [diff] [blame] | 54 | with :ref:`FE_GET_INFO`. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 55 | |
| 56 | The device can be opened in read-only mode, which only allows monitoring |
| 57 | of device status and statistics, or read/write mode, which allows any |
| 58 | kind of use (e.g. performing tuning operations.) |
| 59 | |
| 60 | In a system with multiple front-ends, it is usually the case that |
| 61 | multiple devices cannot be open in read/write mode simultaneously. As |
| 62 | long as a front-end device is opened in read/write mode, other open() |
| 63 | calls in read/write mode will either fail or block, depending on whether |
| 64 | non-blocking or blocking mode was specified. A front-end device opened |
| 65 | in blocking mode can later be put into non-blocking mode (and vice |
| 66 | versa) using the F_SETFL command of the fcntl system call. This is a |
| 67 | standard system call, documented in the Linux manual page for fcntl. |
| 68 | When an open() call has succeeded, the device will be ready for use in |
| 69 | the specified mode. This implies that the corresponding hardware is |
| 70 | powered up, and that other front-ends may have been powered down to make |
| 71 | that possible. |
| 72 | |
| 73 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 74 | Return Value |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 75 | ============ |
| 76 | |
Mauro Carvalho Chehab | 760c701 | 2016-07-04 12:56:17 -0300 | [diff] [blame] | 77 | On success :ref:`open() <frontend_f_open>` returns the new file descriptor. |
| 78 | On error, -1 is returned, and the ``errno`` variable is set appropriately. |
| 79 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 80 | Possible error codes are: |
| 81 | |
| 82 | EACCES |
| 83 | The caller has no permission to access the device. |
| 84 | |
| 85 | EBUSY |
| 86 | The the device driver is already in use. |
| 87 | |
| 88 | ENXIO |
| 89 | No device corresponding to this device special file exists. |
| 90 | |
| 91 | ENOMEM |
| 92 | Not enough kernel memory was available to complete the request. |
| 93 | |
| 94 | EMFILE |
| 95 | The process already has the maximum number of files open. |
| 96 | |
| 97 | ENFILE |
| 98 | The limit on the total number of files open on the system has been |
| 99 | reached. |
| 100 | |
| 101 | ENODEV |
| 102 | The device got removed. |