{
    "content": [
        {
            "type": "text",
            "text": "# lirc(4) (man)\n\n**Summary:** lirc - lirc devices\n\n## See Also\n\n- ir-ctl(1)\n- lircd(8)\n- bpf(2)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (55 lines)\n- **IOCTL COMMANDS** (11 lines) — 2 subsections\n  - Always Supported Commands (8 lines)\n  - Optional Commands (104 lines)\n- **FEATURES** (45 lines)\n- **BUGS** (4 lines)\n- **SEE ALSO** (4 lines)\n- **COLOPHON** (7 lines)\n\n## Full Content\n\n### NAME\n\nlirc - lirc devices\n\n### DESCRIPTION\n\nThe  /dev/lirc*  character  devices  provide a low-level bidirectional interface to infra-red\n(IR) remotes.  Most of these devices can receive, and some can send.  When receiving or send‐\ning data, the driver works in two different modes depending on the underlying hardware.\n\nSome hardware (typically TV-cards) decodes the IR signal internally and provides decoded but‐\nton presses as scancode values.  Drivers for this kind of hardware work in LIRCMODESCANCODE\nmode.  Such hardware usually does not support sending IR signals.  Furthermore, such hardware\ncan only decode a limited set of IR protocols, usually only the protocol of the specific  re‐\nmote which is bundled with, for example, a TV-card.\n\nOther   hardware   provides  a  stream  of  pulse/space  durations.   Such  drivers  work  in\nLIRCMODEMODE2 mode.  Sometimes, this kind of hardware also supports sending IR data.   Such\nhardware  can  be  used  with (almost) any kind of remote.  This type of hardware can also be\nused in LIRCMODESCANCODE mode, in which case the kernel IR decoders  will  decode  the  IR.\nThese decoders can be written in extended BPF (see bpf(2)) and attached to the lirc device.\n\nThe  LIRCGETFEATURES  ioctl (see below) allows probing for whether receiving and sending is\nsupported, and in which modes, amongst other features.\n\nReading input with the LIRCMODEMODE2 mode\nIn the LIRCMODEMODE2 mode, the data returned by read(2) provides 32-bit values representing\na space or a pulse duration.  The time of the duration (microseconds) is encoded in the lower\n24 bits.  The upper 8 bits indicate the type of package:\n\nLIRCMODE2SPACE\nValue reflects a space duration (microseconds).\n\nLIRCMODE2PULSE\nValue reflects a pulse duration (microseconds).\n\nLIRCMODE2FREQUENCY\nValue reflects a frequency (Hz); see the LIRCSETMEASURECARRIERMODE ioctl.\n\nLIRCMODE2TIMEOUT\nValue reflects a space duration (microseconds).  The package reflects a timeout; see  the\nLIRCSETRECTIMEOUTREPORTS ioctl.\n\nReading input with the LIRCMODESCANCODE mode\nIn the LIRCMODESCANCODE mode, the data returned by read(2) reflects decoded button presses,\nin the struct lircscancode.  The scancode is stored in the scancode field, and the IR proto‐\ncol is stored in rcproto.  This field has one the values of the enum rcproto.\n\nWriting output with the LIRCMODEPULSE mode\nThe  data written to the character device using write(2) is a pulse/space sequence of integer\nvalues.  Pulses and spaces are only marked implicitly by their position.  The data must start\nand  end  with  a  pulse, thus it must always include an odd number of samples.  The write(2)\nfunction blocks until the data has been transmitted by the hardware.  If more  data  is  pro‐\nvided than the hardware can send, the write(2) call fails with the error EINVAL.\n\nWriting output with the LIRCMODESCANCODE mode\nThe  data  written to the character devices must be a single struct lircscancode.  The scan‐\ncode and rcproto fields must filled in, all other fields must be 0.  The kernel IR  encoders\nwill  convert the scancode to pulses and spaces.  The protocol or scancode is invalid, or the\nlirc device cannot transmit.\n\n### IOCTL COMMANDS\n\nThe LIRC device's ioctl definition is bound  by  the  ioctl  function  definition  of  struct\nfileoperations,  leaving  us with an unsigned int for the ioctl command and an unsigned long\nfor the argument.  For the purposes of ioctl portability across 32-bit and  64-bit  architec‐\ntures, these values are capped to their 32-bit sizes.\n\n#include <linux/lirc.h>    /* But see BUGS */\nint ioctl(int fd, int cmd, ...);\n\nThe  following  ioctls  can be used to probe or change specific lirc hardware settings.  Many\nrequire a third argument, usually an int.  referred to below as val.\n\n#### Always Supported Commands\n\n/dev/lirc* devices always support the following commands:\n\nLIRCGETFEATURES (void)\nReturns a bit mask of combined features bits; see FEATURES.\n\nIf a device returns an error code for LIRCGETFEATURES, it is safe to assume  it  is  not  a\nlirc device.\n\n#### Optional Commands\n\nSome  lirc  devices  support  the commands listed below.  Unless otherwise stated, these fail\nwith the error ENOTTY if the operation isn't supported, or with the error EINVAL if the oper‐\nation  failed,  or invalid arguments were provided.  If a driver does not announce support of\ncertain features, invoking the corresponding ioctls will fail with the error ENOTTY.\n\nLIRCGETRECMODE (void)\nIf the lirc device has no receiver, this operation fails with the error ENOTTY.   Oth‐\nerwise, it returns the receive mode, which will be one of:\n\nLIRCMODEMODE2\nThe driver returns a sequence of pulse/space durations.\n\nLIRCMODESCANCODE\nThe  driver returns struct lircscancode values, each of which represents a de‐\ncoded button press.\n\nLIRCSETRECMODE (int)\nSet the receive mode.  val is either LIRCMODESCANCODE or  LIRCMODEMODE2.   If  the\nlirc device has no receiver, this operation fails with the error ENOTTY.\n\nLIRCGETSENDMODE (void)\nReturn  the  send  mode.   LIRCMODEPULSE or LIRCMODESCANCODE is supported.  If the\nlirc device cannot send, this operation fails with the error ENOTTY.\n\nLIRCSETSENDMODE (int)\nSet the send mode.  val is either LIRCMODESCANCODE or LIRCMODEPULSE.  If the  lirc\ndevice cannot send, this operation fails with the error ENOTTY.\n\nLIRCSETSENDCARRIER (int)\nSet the modulation frequency.  The argument is the frequency (Hz).\n\nLIRCSETSENDDUTYCYCLE (int)\nSet  the carrier duty cycle.  val is a number in the range [0,100] which describes the\npulse width as a percentage of the total cycle.  Currently, no special meaning is  de‐\nfined for 0 or 100, but the values are reserved for future use.\n\nLIRCGETMINTIMEOUT (void), LIRCGETMAXTIMEOUT (void)\nSome devices have internal timers that can be used to detect when there has been no IR\nactivity for a long time.  This can help lircd(8) in detecting that an  IR  signal  is\nfinished  and can speed up the decoding process.  These operations return integer val‐\nues with the minimum/maximum timeout that can be  set  (microseconds).   Some  devices\nhave a fixed timeout.  For such drivers, LIRCGETMINTIMEOUT and LIRCGETMAXTIMEOUT\nwill fail with the error ENOTTY.\n\nLIRCSETRECTIMEOUT (int)\nSet the integer value for IR inactivity timeout (microseconds).  To be  accepted,  the\nvalue must be within the limits defined by LIRCGETMINTIMEOUT and LIRCGETMAXTIME‐‐\nOUT.  A value of 0 (if supported by the hardware) disables all hardware  timeouts  and\ndata  should  be reported as soon as possible.  If the exact value cannot be set, then\nthe next possible value greater than the given value should be set.\n\nLIRCGETRECTIMEOUT (void)\nReturn the current inactivity timeout (microseconds).  Available since Linux 4.18.\n\nLIRCSETRECTIMEOUTREPORTS (int)\nEnable (val is 1) or disable (val is 0) timeout packages in LIRCMODEMODE2.  The  be‐\nhavior of this operation has varied across kernel versions:\n\n*  Since  Linux  4.16: each time the lirc device is opened, timeout reports are by de‐\nfault enabled for the resulting file descriptor.  The  LIRCSETRECTIMEOUT  opera‐\ntion  can  be  used to disable (and, if desired, to later re-enable) the timeout on\nthe file descriptor.\n\n*  In Linux 4.15 and earlier: timeout reports are disabled by  default,  and  enabling\nthem (via LIRCSETRECTIMEOUT) on any file descriptor associated with the lirc de‐\nvice has the effect of enabling timeouts for all file descriptors referring to that\ndevice (until timeouts are disabled again).\n\nLIRCSETRECCARRIER (int)\nSet  the  upper  bound  of  the receive carrier frequency (Hz).  See LIRCSETRECCAR‐‐\nRIERRANGE.\n\nLIRCSETRECCARRIERRANGE (int)\nSets the lower bound of the receive carrier frequency (Hz).  For this to take  affect,\nfirst set the lower bound using the LIRCSETRECCARRIERRANGE ioctl, and then the up‐\nper bound using the LIRCSETRECCARRIER ioctl.\n\nLIRCSETMEASURECARRIERMODE (int)\nEnable (val is 1) or disable (val is 0) the measure mode.  If enabled, from  the  next\nkey  press  on,  the  driver will send LIRCMODE2FREQUENCY packets.  By default, this\nshould be turned off.\n\nLIRCGETRECRESOLUTION (void)\nReturn the driver resolution (microseconds).\n\nLIRCSETTRANSMITTERMASK (int)\nEnable the set of transmitters specified in val, which contains a bit mask where  each\nenabled transmitter is a 1.  The first transmitter is encoded by the least significant\nbit, and so on.  When an invalid bit mask is given, for example  a  bit  is  set  even\nthough  the device does not have so many transmitters, this operation returns the num‐\nber of available transmitters and does nothing otherwise.\n\nLIRCSETWIDEBANDRECEIVER (int)\nSome devices are equipped with a special wide band receiver which is  intended  to  be\nused to learn the output of an existing remote.  This ioctl can be used to enable (val\nequals 1) or disable (val equals 0) this functionality.  This might be useful for  de‐\nvices that otherwise have narrow band receivers that prevent them to be used with cer‐\ntain remotes.  Wide band receivers may also be more precise.  On the other hand, their\ndisadvantage usually is reduced range of reception.\n\nNote:  wide band receiver may be implicitly enabled if you enable carrier reports.  In\nthat case, it will be disabled as soon as you disable carrier reports.  Trying to dis‐\nable a wide band receiver while carrier reports are active will do nothing.\n\n### FEATURES\n\nthe  LIRCGETFEATURES  ioctl returns a bit mask describing features of the driver.  The fol‐\nlowing bits may be returned in the mask:\n\nLIRCCANRECMODE2\nThe driver is capable of receiving using LIRCMODEMODE2.\n\nLIRCCANRECSCANCODE\nThe driver is capable of receiving using LIRCMODESCANCODE.\n\nLIRCCANSETSENDCARRIER\nThe driver supports changing the modulation frequency using LIRCSETSENDCARRIER.\n\nLIRCCANSETSENDDUTYCYCLE\nThe driver supports changing the duty cycle using LIRCSETSENDDUTYCYCLE.\n\nLIRCCANSETTRANSMITTERMASK\nThe driver  supports  changing  the  active  transmitter(s)  using  LIRCSETTRANSMIT‐‐\nTERMASK.\n\nLIRCCANSETRECCARRIER\nThe  driver supports setting the receive carrier frequency using LIRCSETRECCARRIER.\nAny lirc device since the drivers were merged  in  kernel  release  2.6.36  must  have\nLIRCCANSETRECCARRIERRANGE set if LIRCCANSETRECCARRIER feature is set.\n\nLIRCCANSETRECCARRIERRANGE\nThe  driver  supports LIRCSETRECCARRIERRANGE.  The lower bound of the carrier must\nfirst  be  set  using  the  LIRCSETRECCARRIERRANGE   ioctl,   before   using   the\nLIRCSETRECCARRIER ioctl to set the upper bound.\n\nLIRCCANGETRECRESOLUTION\nThe driver supports LIRCGETRECRESOLUTION.\n\nLIRCCANSETRECTIMEOUT\nThe driver supports LIRCSETRECTIMEOUT.\n\nLIRCCANMEASURECARRIER\nThe  driver supports measuring of the modulation frequency using LIRCSETMEASURECAR‐‐\nRIERMODE.\n\nLIRCCANUSEWIDEBANDRECEIVER\nThe driver supports learning mode using LIRCSETWIDEBANDRECEIVER.\n\nLIRCCANSENDPULSE\nThe driver supports sending using LIRCMODEPULSE or LIRCMODESCANCODE\n\n### BUGS\n\nUsing these devices requires the kernel source header file lirc.h.  This file is  not  avail‐\nable  before  kernel  release  4.6.   Users  of  older  kernels could use the file bundled in\n⟨http://www.lirc.org⟩.\n\n### SEE ALSO\n\nir-ctl(1), lircd(8), bpf(2)\n\nhttps://www.kernel.org/doc/html/latest/media/uapi/rc/lirc-dev.html\n\n### COLOPHON\n\nThis page is part of release 5.10 of the Linux  man-pages  project.   A  description  of  the\nproject,  information about reporting bugs, and the latest version of this page, can be found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2019-03-06                                      LIRC(4)\n\n"
        }
    ],
    "structuredContent": {
        "command": "lirc",
        "section": "4",
        "mode": "man",
        "summary": "lirc - lirc devices",
        "synopsis": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "ir-ctl",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ir-ctl/1/json"
            },
            {
                "name": "lircd",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/lircd/8/json"
            },
            {
                "name": "bpf",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/bpf/2/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 55,
                "subsections": []
            },
            {
                "name": "IOCTL COMMANDS",
                "lines": 11,
                "subsections": [
                    {
                        "name": "Always Supported Commands",
                        "lines": 8
                    },
                    {
                        "name": "Optional Commands",
                        "lines": 104
                    }
                ]
            },
            {
                "name": "FEATURES",
                "lines": 45,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "COLOPHON",
                "lines": 7,
                "subsections": []
            }
        ]
    }
}