154f38fcaSMauro Carvalho Chehab.. Permission is granted to copy, distribute and/or modify this
254f38fcaSMauro Carvalho Chehab.. document under the terms of the GNU Free Documentation License,
354f38fcaSMauro Carvalho Chehab.. Version 1.1 or any later version published by the Free Software
454f38fcaSMauro Carvalho Chehab.. Foundation, with no Invariant Sections, no Front-Cover Texts
554f38fcaSMauro Carvalho Chehab.. and no Back-Cover Texts. A copy of the license is included at
654f38fcaSMauro Carvalho Chehab.. Documentation/userspace-api/media/fdl-appendix.rst.
754f38fcaSMauro Carvalho Chehab..
854f38fcaSMauro Carvalho Chehab.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho Chehab.. _lirc-read:
1154f38fcaSMauro Carvalho Chehab
1254f38fcaSMauro Carvalho Chehab***********
1354f38fcaSMauro Carvalho ChehabLIRC read()
1454f38fcaSMauro Carvalho Chehab***********
1554f38fcaSMauro Carvalho Chehab
1654f38fcaSMauro Carvalho ChehabName
1754f38fcaSMauro Carvalho Chehab====
1854f38fcaSMauro Carvalho Chehab
1954f38fcaSMauro Carvalho Chehablirc-read - Read from a LIRC device
2054f38fcaSMauro Carvalho Chehab
2154f38fcaSMauro Carvalho Chehab
2254f38fcaSMauro Carvalho ChehabSynopsis
2354f38fcaSMauro Carvalho Chehab========
2454f38fcaSMauro Carvalho Chehab
2554f38fcaSMauro Carvalho Chehab.. code-block:: c
2654f38fcaSMauro Carvalho Chehab
2754f38fcaSMauro Carvalho Chehab    #include <unistd.h>
2854f38fcaSMauro Carvalho Chehab
2954f38fcaSMauro Carvalho Chehab
3054f38fcaSMauro Carvalho Chehab.. c:function:: ssize_t read( int fd, void *buf, size_t count )
3154f38fcaSMauro Carvalho Chehab    :name: lirc-read
3254f38fcaSMauro Carvalho Chehab
3354f38fcaSMauro Carvalho Chehab
3454f38fcaSMauro Carvalho ChehabArguments
3554f38fcaSMauro Carvalho Chehab=========
3654f38fcaSMauro Carvalho Chehab
3754f38fcaSMauro Carvalho Chehab``fd``
3854f38fcaSMauro Carvalho Chehab    File descriptor returned by ``open()``.
3954f38fcaSMauro Carvalho Chehab
4054f38fcaSMauro Carvalho Chehab``buf``
4154f38fcaSMauro Carvalho Chehab   Buffer to be filled
4254f38fcaSMauro Carvalho Chehab
4354f38fcaSMauro Carvalho Chehab``count``
4454f38fcaSMauro Carvalho Chehab   Max number of bytes to read
4554f38fcaSMauro Carvalho Chehab
4654f38fcaSMauro Carvalho ChehabDescription
4754f38fcaSMauro Carvalho Chehab===========
4854f38fcaSMauro Carvalho Chehab
4954f38fcaSMauro Carvalho Chehab:ref:`read() <lirc-read>` attempts to read up to ``count`` bytes from file
5054f38fcaSMauro Carvalho Chehabdescriptor ``fd`` into the buffer starting at ``buf``.  If ``count`` is zero,
5154f38fcaSMauro Carvalho Chehab:ref:`read() <lirc-read>` returns zero and has no other results. If ``count``
5254f38fcaSMauro Carvalho Chehabis greater than ``SSIZE_MAX``, the result is unspecified.
5354f38fcaSMauro Carvalho Chehab
5454f38fcaSMauro Carvalho ChehabThe exact format of the data depends on what :ref:`lirc_modes` a driver
5554f38fcaSMauro Carvalho Chehabuses. Use :ref:`lirc_get_features` to get the supported mode, and use
5654f38fcaSMauro Carvalho Chehab:ref:`lirc_set_rec_mode` set the current active mode.
5754f38fcaSMauro Carvalho Chehab
5854f38fcaSMauro Carvalho ChehabThe mode :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>` is for raw IR,
5954f38fcaSMauro Carvalho Chehabin which packets containing an unsigned int value describing an IR signal are
6054f38fcaSMauro Carvalho Chehabread from the chardev.
6154f38fcaSMauro Carvalho Chehab
6254f38fcaSMauro Carvalho ChehabAlternatively, :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` can be available,
6354f38fcaSMauro Carvalho Chehabin this mode scancodes which are either decoded by software decoders, or
6454f38fcaSMauro Carvalho Chehabby hardware decoders. The :c:type:`rc_proto` member is set to the
6554f38fcaSMauro Carvalho Chehab:ref:`IR protocol <Remote_controllers_Protocols>`
6654f38fcaSMauro Carvalho Chehabused for transmission, and ``scancode`` to the decoded scancode,
6754f38fcaSMauro Carvalho Chehaband the ``keycode`` set to the keycode or ``KEY_RESERVED``.
6854f38fcaSMauro Carvalho Chehab
6954f38fcaSMauro Carvalho Chehab
7054f38fcaSMauro Carvalho ChehabReturn Value
7154f38fcaSMauro Carvalho Chehab============
7254f38fcaSMauro Carvalho Chehab
7354f38fcaSMauro Carvalho ChehabOn success, the number of bytes read is returned. It is not an error if
7454f38fcaSMauro Carvalho Chehabthis number is smaller than the number of bytes requested, or the amount
7554f38fcaSMauro Carvalho Chehabof data required for one frame.  On error, -1 is returned, and the ``errno``
7654f38fcaSMauro Carvalho Chehabvariable is set appropriately.
77