{
    "mode": "man",
    "parameter": "lirc",
    "section": "4",
    "url": "https://www.chedong.com/phpMan.php/man/lirc/4/json",
    "generated": "2026-10-04T06:33:23Z",
    "sections": {
        "NAME": {
            "content": "lirc - lirc devices\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  /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.  Such hardware can be used with (almost) any kind of remote.  This type\nof hardware can also be used in LIRCMODESCANCODE mode, in which case the kernel IR decoders\nwill decode the IR.  These decoders can be written in extended BPF (see bpf(2)) and  attached\nto the lirc device.  Sometimes, this kind of hardware also supports sending IR data.\n\nThe  LIRCGETFEATURES  ioctl (see below) allows probing for whether receiving and sending is\nsupported, and in which modes, amongst other features.\n",
            "subsections": [
                {
                    "name": "Reading input with the LIRC_MODE_MODE2 mode",
                    "content": "In 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.  Pulse (also known as flash) indicates a duration of infrared light being  detected,\nand  space  (also  known  as  gap) indicates a duration with no infrared.  If the duration of\nspace exceeds the inactivity timeout, a special timeout package is delivered, which marks the\nend of a message.  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\nLIRCMODE2OVERFLOW\nThe  IR  receiver  encountered  an overflow, and as a result data is missing (since Linux\n5.18).\n"
                },
                {
                    "name": "Reading input with the LIRC_MODE_SCANCODE mode",
                    "content": "In 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"
                },
                {
                    "name": "Writing output with the LIRC_MODE_PULSE mode",
                    "content": "The 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"
                },
                {
                    "name": "Writing output with the LIRC_MODE_SCANCODE mode",
                    "content": "The  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"
                }
            ]
        },
        "IOCTL COMMANDS": {
            "content": "#include <linux/lirc.h>    /* But see BUGS */\n\nint ioctl(int fd, int cmd, int *val);\n\nThe following ioctl(2) operations are provided by the  lirc  character  device  to  probe  or\nchange specific lirc hardware settings.\n",
            "subsections": [
                {
                    "name": "Always Supported Commands",
                    "content": "/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"
                },
                {
                    "name": "Optional Commands",
                    "content": "Some 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)\nLIRCGETMAXTIMEOUT(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 5.17: timeout packages are always enabled and this ioctl is a no-op.\n\n•  Since Linux 4.16: timeout packages are enabled by default.  Each time the lirc  de‐\nvice  is opened, the LIRCSETRECTIMEOUT operation can be used to disable (and, if\ndesired, to later re-enable) the timeout on the file descriptor.\n\n•  In Linux 4.15 and earlier: timeout packages 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"
                }
            ]
        },
        "FEATURES": {
            "content": "the  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  Linux   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",
            "subsections": []
        },
        "BUGS": {
            "content": "Using these devices requires the kernel source header file lirc.h.  This file is  not  avail‐\nable   before   Linux   4.6.    Users  of  older  kernels  could  use  the  file  bundled  in\nhttp://www.lirc.org.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ir-ctl(1), lircd(8), bpf(2)\n\nhttps://www.kernel.org/doc/html/latest/userspace-api/media/rc/lirc-dev.html\n\nLinux man-pages 6.7                          2023-10-31                                      lirc(4)",
            "subsections": []
        }
    },
    "summary": "lirc - lirc devices",
    "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"
        }
    ]
}