Differences
This shows you the differences between two versions of the page.
| — |
doc:howto:lirc-audio_alsa [2012/11/08 18:15] (current) danitool created: LIRC audio_alsa howto |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== LIRC audio_alsa ====== | ||
| + | [[http://www.lirc.org/|LIRC]] is a package that allows you to decode and send infra-red signals of many (but not all) commonly used remote controls. | ||
| + | Be aware you'll need a **sound card** with microphone input. A cheap usb sound card can do the job. | ||
| + | |||
| + | The audio_alsa module lets you to use a soundcard input to receive infrarred signals. The basic idea is that the output of the IR module (somewhere in the range from 0 to ~3-4V) can be limited by using the attenuator built into every audio-card (also known as "mixer sliders"). | ||
| + | |||
| + | ===== Prepare your hardware ===== | ||
| + | This is a schematic for connecting the IR module to our soundcard input \\ | ||
| + | {{:inbox:howto:lirc-audio_alsa.jpg?500|}} \\ | ||
| + | A TSOP1736 IR module also works. The +5V should be as stable as possible to avoid power supply disturbances. | ||
| + | |||
| + | ===== Prepare your your software ===== | ||
| + | To use the audio_alsa module you'll need to build Openwrt with the package lirc and alsamixer. Install both before building your own firmware. | ||
| + | <code>./scripts/feeds update -a | ||
| + | ./scripts/feeds install lirc alsa-utils | ||
| + | </code> | ||
| + | | {{:meta:icons:tango:package-x-generic.png|}} | The lirc package is not built as default with //audio_alsa//, and it seems partially broken. As a result of this you must modify the Makefile for lirc. Or just download this fixed one: \\ [[https://files.myopera.com/danitool/livebox/wifiradio/lirc-audio_alsa-AA.zip|lirc-audio_alsa-AA.zip]] \\ Prepared to work with OpenWrt Attitude Adjustment, but it may also work with Backfire. Replace the lirc directory under feeds with this new one. | | ||
| + | |||
| + | As usually build your custom firmware but select alsa-utils, lirc: | ||
| + | <code> | ||
| + | Location: | ||
| + | -> Utilities | ||
| + | </code> | ||
| + | <code> | ||
| + | ┌─────────────────────────────────── Utilities ───────────────────────────────────┐ | ||
| + | │ ┌─────────────────────────────────────────────────────────────────────────────┐ │ | ||
| + | │ │ Boot Loaders ---> │ │ | ||
| + | │ │ Editors ---> │ │ | ||
| + | │ │ Filesystem ---> │ │ | ||
| + | │ │ Terminal ---> │ │ | ||
| + | │ │ disc ---> │ │ | ||
| + | │ │ <*> alsa-utils............ ALSA (Advanced Linux Sound Architecture) utilitie│ │ | ||
| + | │ │ < > alsa-utils-seq.................................. ALSA sequencer utilitie│ │ | ||
| + | │ │ < > alsa-utils-tests.......... ALSA utilities test data (adds ~1.3M to image│ │ | ||
| + | │ │ < > bzip2.................................... bzip2 is a compression utility│ │ | ||
| + | │ │ < > cal................................................... display a calenda│ │ | ||
| + | │ │ < > comgt............................... Option/Vodafone 3G/GPRS control too│ │ | ||
| + | │ │ < > dmesg............................ print or control the kernel ring buffe│ │ | ||
| + | │ │ < > dropbearconvert.......................... Utility for converting SSH key│ │ | ||
| + | │ │ < > fconfig..................................... RedBoot configuration edito│ │ | ||
| + | │ │ < > flock.................................... manage locks from shell script│ │ | ||
| + | │ │ < > gdb......................................................... GNU Debugge│ │ | ||
| + | │ │ < > gdbserver................................. Remote server for GNU Debugge│ │ | ||
| + | │ │ < > getopt.................................. parse command options (enhanced│ │ | ||
| + | │ │ < > gpioctl................................... Tool for controlling gpio pin│ │ | ||
| + | │ │ < > hwclock.................................. query or set the hardware cloc│ │ | ||
| + | │ │ < > iconv................................... Character set conversion utilit│ │ | ||
| + | │ │ < > iwcap.................................... Simple radiotap capture utilit│ │ | ||
| + | │ │ < > iwinfo.......................... Generalized Wireless Information utilit│ │ | ||
| + | │ │ --- jshn................................................. JSON SHell Notatio│ │ | ||
| + | │ │ < > kexec-tools.......................................... Kernel boots kerne│ │ | ||
| + | │ │ < > ldconfig............................... Shared library path configuratio│ │ | ||
| + | │ │ < > ldd.................................................... LDD trace utilit│ │ | ||
| + | │ │ <*> lirc................................ LIRC - Linux Infrared Remote Contro│ │ | ||
| + | │ │ < > logger......... a shell command interface to the syslog system log modul│ │ | ||
| + | │ │ < > look......................... display lines beginning with a given strin│ │ | ||
| + | │ └─v(+)────────────────────────────────────────────────────────────────────────┘ │ | ||
| + | ├─────────────────────────────────────────────────────────────────────────────────┤ | ||
| + | │ <Select> < Exit > < Help > │ | ||
| + | └─────────────────────────────────────────────────────────────────────────────────┘ | ||
| + | </code> | ||
| + | and lirc utitilities: | ||
| + | <code> | ||
| + | Location: | ||
| + | -> Utilities | ||
| + | -> lirc | ||
| + | </code> | ||
| + | <code> | ||
| + | ┌─────────── lirc............. LIRC - Linux Infrared Remote Control ────────────┐ | ||
| + | │ ┌───────────────────────────────────────────────────────────────────────────┐ │ | ||
| + | │ │ --- lirc.................. LIRC - Linux Infrared Remote Control │ │ | ||
| + | │ │ <*> lircdaemonadd...................... Daemon Additional Files │ │ | ||
| + | │ │ <*> lirctools....................................... LIRC tools │ │ | ||
| + | │ │ │ │ | ||
| + | │ └───────────────────────────────────────────────────────────────────────────┘ │ | ||
| + | ├───────────────────────────────────────────────────────────────────────────────┤ | ||
| + | │ <Select> < Exit > < Help > │ | ||
| + | └───────────────────────────────────────────────────────────────────────────────┘ | ||
| + | </code> | ||
| + | |||
| + | Build openwrt, and flash your custom firmware. Now you have lirc prepared to work. | ||
| + | |||
| + | | {{:meta:icons:tango:dialog-information.png|}} | Note the file **/etc/lircd.conf** is specific for your remote. You'll may need to use [[http://www.lirc.org/html/irrecord.html|irrecord]] to get one for your own remote if you don't find any in the [[http://lirc.sourceforge.net/remotes/|lirc database]]. | | ||
| + | |||
| + | ===== Make it work ===== | ||
| + | Execute the lirc daemon | ||
| + | <code> | ||
| + | mkdir /var/run/lirc | ||
| + | lircd --driver=audio_alsa -d plughw@24000 | ||
| + | </code> | ||
| + | |||
| + | Now execute irw, to test your remote, the codes are shown when you press any button. | ||
| + | <code>root@OpenWrt:/# irw | ||
| + | 00000000000005e9 00 + rct3004 | ||
| + | 00000000000005ea 00 - rct3004 | ||
| + | 00000000000005ea 01 - rct3004 | ||
| + | 00000000000005dd 00 power rct3004 | ||
| + | 00000000000005d0 00 3 rct3004 | ||
| + | 00000000000005d0 01 3 rct3004 | ||
| + | 00000000000005c9 00 5 rct3004 | ||
| + | 00000000000005c9 01 5 rct3004 | ||
| + | 00000000000005c1 00 4 rct3004 | ||
| + | 00000000000005c1 01 4 rct3004</code> | ||
| + | If nothing is shown you may need to calibrate the infrared receiver with alsamixer: | ||
| + | <HTML><table><tr><td><code> | ||
| + | ┌───────── AlsaMixer v1.0.24.2 ─────────┐ | ||
| + | │ Card: Generic USB Audio Device │ | ||
| + | │ Chip: USB Mixer │ | ||
| + | │ View: Playback │ | ||
| + | │ Item: Speaker [dB gain: -0.06, -0.06] │ | ||
| + | │ ┌──┐ ┌──┐ │ | ||
| + | │ │▒▒│ │ │ │ | ||
| + | │ │▒▒│ │ │ │ | ||
| + | │ │▒▒│ │ │ │ | ||
| + | │ │▒▒│ │ │ │ | ||
| + | │ │▒▒│ │ │ │ | ||
| + | │ │▒▒│ │▒▒│ │ | ||
| + | │ │▒▒│ │▒▒│ │ | ||
| + | │ │▒▒│ │▒▒│ │ | ||
| + | │ │▒▒│ │▒▒│ │ | ||
| + | │ │▒▒│ │▒▒│ │ | ||
| + | │ ├──┤ ├──┤ ┌──┐ │ | ||
| + | │ │OO│ │MM│ │OO│ │ | ||
| + | │ └──┘ └──┘ └──┘ │ | ||
| + | │ 100<>100 52 │ | ||
| + | │ < Speaker > Mic Auto Gain C │ | ||
| + | └───────────────────────────────────────┘ | ||
| + | </code></td></tr></table></HTML> | ||
| + | Sometimes is better to use Auto Gain other times not (**m** key to disable/enable). So play with it together with the next control: \\ | ||
| + | **Press F4** to enter the Capture control. | ||
| + | <HTML><table><tr><td><code> | ||
| + | ┌───────── AlsaMixer v1.0.24.2 ─────────┐ | ||
| + | │ Card: Generic USB Audio Device │ | ||
| + | │ Chip: USB Mixer │ | ||
| + | │ View: Capture │ | ||
| + | │ Item: Mic [dB gain: 14.88] │ | ||
| + | │ │ | ||
| + | │ ┌──┐ │ | ||
| + | │ │ │ │ | ||
| + | │ │ │ │ | ||
| + | │ │ │ │ | ||
| + | │ │ │ │ | ||
| + | │ │▒▒│ │ | ||
| + | │ │▒▒│ │ | ||
| + | │ │▒▒│ │ | ||
| + | │ │▒▒│ │ | ||
| + | │ │▒▒│ │ | ||
| + | │ │▒▒│ │ | ||
| + | │ L└──┘R │ | ||
| + | │ CAPTURE │ | ||
| + | │ 62 │ | ||
| + | │ < Mic > │ | ||
| + | └───────────────────────────────────────┘ | ||
| + | </code></td></tr></table></HTML> | ||
| + | Now play with the gain (arrow up/down) until your remote shows its codes with irw. Once calibrated press Esc key to exit alsamixer. | ||
| + | |||
| + | ==== irexec ==== | ||
| + | Ok nothing new here, just configure [[http://www.lirc.org/html/configure.html#lircrc_format|lircrc]] as described in the LIRC website. The file /etc/wifiradio/lircrc is an example. Run the [[http://www.lirc.org/html/irexec.html|irexec]] daemon with a command like this: | ||
| + | <code>irexec --daemon /etc/wifiradio/lircrc</code> | ||
| + | Now everytime you press a button in your remote, irexec will execute the associated commands in the lircrc file. | ||
| + | |||
| + | You can put the commands to calibrate alsamixer and execute commands in /etc/rc.local, to autostart lircd and irexec once you got it working. | ||
| + | <code>mkdir /var/run/lirc | ||
| + | amixer -q set Mic capture 62% | ||
| + | lircd --driver=audio_alsa -d plughw@24000 | ||
| + | irexec --daemon /etc/wifiradio/lircrc | ||
| + | </code> | ||
| + | |||
| + | ===== Notes ===== | ||
| + | Successfully tested with a [[toh:inventel:DV4210|Livebox 1]] router under Backfire, using a CSOUNDU Conceptronic usb audio card, and TSOP1736 --- //danitool 2012/11/04 15:02// | ||
| + | |||
| + | ===== Tags ===== | ||
| + | {{tag>wip lirc}} | ||
doc/howto/lirc-audio_alsa.txt · Last modified: 2012/11/08 18:15 by danitool
