# Avermedia 771 DVB-T remote control...[Solved]

## rlholgate

Hi

Has anyone got the remote control working on an Avermedia 771 DVB-T digital television tuner card? The TV tuner works properly - I get good picture and sound, just don't know how to setup the remote control. I am using gentoo-dev-sources, kernel version 2.6.10-r6.

If so can you post some info on what you did?

 (URL for card, fyi: http://www.avermedia.com/cgi-bin/products_digitvtuner_dvbt771.asp).Last edited by rlholgate on Mon Feb 28, 2005 12:40 pm; edited 1 time in total

----------

## rlholgate

Well I'm gonna reply to my own post in case somebody else has this problem. This information is current as of 28 Feb 2005. Look for a new kernel to include a newer video4linux drivers so you don't have to do all this....

EDIT: Don't read this post too carefully, I've rewritten it below with somewhat better understanding. /EDIT.

1) Get a recent video4linux from www.bytesex.org, I used CVS snapshot from 24 Feb 2005.

2) Compile it, install modules. Modules wind up in /lib/modules/<kernel>/v4l2

3) Make sure you will load the right modules in case you have the old ones hanging around (i.e. the bttv that comes with the kernel for example). I'm a bit of hacker here I'm afraid - I did this by removing the old modules. Anyone tell me the right way to do this? 

```
# Basically for every kernel module in v4l2 directory, search the kernel

# module tree and if you find a module with the same name delete it (hack city!)

# Don't do this if you know better - I don't

> cd /lib/modules/<kernel>/v4l2

> for file in *; do find ../kernel -name $file; done | xargs rm
```

4) Run modules-update

5) Modprobe DVB modules.

```
modprobe bttv

modprobe bt878

modprobe dvb-bt8xx
```

6) Modprobe remote control modules.

```
modprobe ir-kbd-gpio

modprobe ir-kbd-i2c
```

7) Modprobe event device module. (When compiling kernel this is under Device Drivers -> Input Devices -> Event Interface)

```
modprobe evdev
```

8) In my case I now have these devices:

```
drwxr-xr-x  1 root root      0 Jan  1  1970 /dev/input

crw-r--r--  1 root root 13, 64 Jan  1  1970 /dev/input/event0

crw-r--r--  1 root root 13, 65 Jan  1  1970 /dev/input/event1

crw-r--r--  1 root root 13, 66 Jan  1  1970 /dev/input/event2

crw-r--r--  1 root root 13, 63 Jan  1  1970 /dev/input/mice

crw-r--r--  1 root root 13, 32 Jan  1  1970 /dev/input/mouse0
```

If I cat from each "event" device (e.g. cat < event0) I quickly discover that event0 is the keyboard (get output when typing), event1 is the mouse (get output when move mouse), event2 is the remote control (get output when pressing remote buttons).

I also have this in /proc/bus/input/devices. You can see it lists keyboard, mouse and remote control as input devices.

```
I: Bus=0011 Vendor=0001 Product=0001 Version=ab41

N: Name="AT Translated Set 2 keyboard"

P: Phys=isa0060/serio0/input0

H: Handlers=kbd event0

B: EV=120013

B: KEY=4 2000000 3802078 f840d001 f2ffffdf ffefffff ffffffff fffffffe

B: MSC=10

B: LED=7

I: Bus=0011 Vendor=0002 Product=0005 Version=0000

N: Name="ImPS/2 Generic Wheel Mouse"

P: Phys=isa0060/serio1/input0

H: Handlers=mouse0 event1

B: EV=7

B: KEY=70000 0 0 0 0 0 0 0 0

B: REL=103

I: Bus=0001 Vendor=1461 Product=0771 Version=0001

N: Name="bttv IR (card=123)"

P: Phys=pci-0000:00:13.0/ir0

H: Handlers=kbd event2

B: EV=100003

B: KEY=fcb10 100040 0 0 0 0 2018000 180 1 9e0000 7bb80 0 0
```

9) Emerge lirc like so:

```
LIRC_OPTS="--with-driver=devinput" emerge lirc
```

10) Configure lirc options. Edit /etc/conf.d/lircd, in the file put something like the following. Change event2 to whatever your remote's eventN is.

```
LIRCD_OPTS="-H dev/input -d /dev/input/event2"
```

11) Install correct /etc/lircd.conf for this remote, I found one here: http://lirc.sourceforge.net/remotes/devinput/AVerTV_DVB-T_771 (Note: this config might have the up and down buttons reversed I think).

12) Now start lircd daemon: /etc/init.d/lircd start

13) Quick check of ps ensures we got the right command line options there:

```
# ps -ef | grep lircd

root     31306     1  0 23:09 ?        00:00:00 /usr/sbin/lircd -H dev/input -d /dev/input/event2
```

14) Now run irw to test. Press buttons on the remote and see output. Kill irw and use your remote to scroll windows. Hooray!

If irw or lircd gives you trouble try cat /var/log/everything/current and look for messages.Last edited by rlholgate on Mon Feb 27, 2006 10:40 pm; edited 2 times in total

----------

## rlholgate

UPDATE: This may save someone some time -

In Kernel 2.6.11-gentoo-r4 some of the above hoop-jumping is no longer required. The ir-kbd-gpio module included with that kernel understands the Avermedia 771 remote without the need to get V4L from the CVS tree. I.e. using 2.6.11-gentoo-r4 you can skip steps 1 through 4.

----------

## ChileVerde

Excellent guide, helped me a lot

I got it working w/o loading these modules:

```
modprobe ir-kbd-gpio

modprobe ir-kbd-i2c
```

Those are used for kbd simulation (AFAIK), so they are not needed for lircd

----------

## rlholgate

Interesting - how did you configure LIRC in that case?

----------

## Matteo Azzali

I've configured lirc for Cinergy T2 using this tutorial and modifying here and there

(check https://forums.gentoo.org/viewtopic-t-360615-highlight-.html ).

But I've also found that evdev isn't safe: If I unplug my joypad, remote switch

from event3 to event2, if I replug joypad, it get event3 causing lirc infinite-loop

(consuming lots of cpu-time). To solve this would be needed to add an udev rule

to link the device in univoque way (as js0 is surely joypad, mice is surely mouse, etc.)

But I haven't found the remote KERNEL==  name to use (should be general, for every

dvb-remote I think...)

----------

## rlholgate

I've actually stopped using lirc now. When using the ir-kbd-gpio module the remote emulates a keyboard directly, so the lirc steps aren't necessary. I.e all you need is steps 5 and 6. Then its a matter of configuring the keybindings with loadkeys, etc. I'm not totally satisfied with it - numlock plays havoc with the meaning of the numeric remote buttons (because they're emulating the numeric keypad) and the "up" and "down" on the remote are reversed with respect to the keyboard keypad, so you run into issues with that too. 

I briefly tried using the lirc_gpio module as described in the following link, but haven't gotten far with that. No time, no time!

lirc_gpio for Avermedia 771: http://sourceforge.net/mailarchive/message.php?msg_id=7719048

If anyone has gotten the keybindings for this remote working really well I'd love to hear from you.

----------

## Matteo Azzali

dunno if is the same for you, but without lirc I have many many issues:

1) not all key recognized (solved with lirc)

2) If I press a key (eg:1) and then press another key (eg:2) the second key pressed is recognized

   as the first one (eg:1). (solved with lirc)

3) lots of repeats for every keypressed,even doin fast(8 without lirc, 1-2 with my lirc configuration)

I'm using kernel 2.6.12-r7 drivers.

----------

## Matteo Azzali

If someone else have the issue "lirc stopping to work cause you plugged a new usb input device (joypad,mouse etc)

and the eventX device of the remote changed his X (eg: from event2 to event3),

I found a way to solve my issue (terratec cinergy T2) and, adapring the grep line, can be used also for your card.

If you need, check This Link

----------

## rlholgate

This is an updated version of the second post in this thread.

From what I can tell there are two ways to configure the remote for the Avermedia 771. 

The other way (i.e. the way I have not used) is to use the lirc_gpio module with a whole pile of options, as described here: http://sourceforge.net/mailarchive/message.php?msg_id=7719048  I haven't done this myself, so not sure what LIRC driver should be used.

The way I've done it is using the ir-kbd-gpio module which AFAICT is an alternative to lirc_gpio. I'm kind of going to assume knowledge of how to build most of the modules listed in the steps below, as most are well enough documented.

1) Modprobe DVB modules.

```
modprobe bttv

modprobe bt878

modprobe dvb-bt8xx
```

Truth be told its probably enough just to modprobe dvb-bt8xx and the others will auto load.

2) Modprobe event device module. (When compiling kernel this is under Device Drivers -> Input Devices -> Event Interface). Also modprobe ir common module and gpio module. Note that above I also said to modprobe ir-kbd-i2c. In fact you only need one or the other of the gpio or i2c modules. For the Avermedia 771 you need ir-kbd-gpio. 

```
modprobe evdev

modprobe ir-common

modprobe ir-kbd-gpio
```

EDIT (May 2006): As of kernel 2.6.16 the ir-kbd-gpio module has merged into the bttv module, so you no longer need to load ir-kbd-gpio or ir-common as described here. For kernel 2.6.16+ just load evdev. /EDIT

3) In my case I now have these devices:

```
drwxr-xr-x  1 root root      0 Jan  1  1970 /dev/input

crw-r--r--  1 root root 13, 64 Jan  1  1970 /dev/input/event0

crw-r--r--  1 root root 13, 65 Jan  1  1970 /dev/input/event1

crw-r--r--  1 root root 13, 66 Jan  1  1970 /dev/input/event2

crw-r--r--  1 root root 13, 63 Jan  1  1970 /dev/input/mice

crw-r--r--  1 root root 13, 32 Jan  1  1970 /dev/input/mouse0
```

If I cat from each "event" device (e.g. cat < event0) I quickly discover that event0 is the keyboard (get output when typing), event1 is the mouse (get output when move mouse), event2 is the remote control (get output when pressing remote buttons).

I also have this in /proc/bus/input/devices. You can see it lists keyboard, mouse and remote control as input devices.

```
I: Bus=0011 Vendor=0001 Product=0001 Version=ab41

N: Name="AT Translated Set 2 keyboard"

P: Phys=isa0060/serio0/input0

H: Handlers=kbd event0

B: EV=120013

B: KEY=4 2000000 3802078 f840d001 f2ffffdf ffefffff ffffffff fffffffe

B: MSC=10

B: LED=7

I: Bus=0011 Vendor=0002 Product=0005 Version=0000

N: Name="ImPS/2 Generic Wheel Mouse"

P: Phys=isa0060/serio1/input0

H: Handlers=mouse0 event1

B: EV=7

B: KEY=70000 0 0 0 0 0 0 0 0

B: REL=103

I: Bus=0001 Vendor=1461 Product=0771 Version=0001

N: Name="bttv IR (card=123)"

P: Phys=pci-0000:00:13.0/ir0

H: Handlers=kbd event2

B: EV=100003

B: KEY=fcb10 100040 0 0 0 0 2018000 180 1 9e0000 7bb80 0 0
```

You can actually use the remote just like this if you want to. In this state it emulates a keyboard. There are some problems with it however, as noted above - specifically not all the remote keys translate nicely into keyboard keys, and you will have problems with repeat keypresses. It's better to use lirc to perform key translation, and debounce the keys.

4) Emerge lirc like so:

```
LIRC_OPTS="--with-driver=devinput" emerge lirc
```

5) Configure lirc options. Edit /etc/conf.d/lircd, in the file put something like the following. Change event2 to whatever your remote's eventN is.

```
LIRCD_OPTS="-H dev/input -d /dev/input/event2"
```

6) Install correct /etc/lircd.conf for this remote. For me this one works nicely, it came to me courtesy of a kind person on the linux-dvb mailing list, for which I am most greatful :-)

```

# Please make this file available to others

# by sending it to <lirc@bartelmus.de>

#

# this config file was automatically generated

# using lirc-0.8.0-CVS(all) on Sat Dec 17 00:15:43 2005

#

# contributed by Andreas Witte

#

# brand:                       /root/irtestfile

# model no. of remote control:

# devices being controlled by this remote:

#

begin remote

  name  Avermedia771

  bits           16

  eps            30

  aeps          100

  one             0     0

  zero            0     0

  pre_data_bits   16

  pre_data       0x8001

  gap          135814

  toggle_bit      0

      begin codes

          source                   0x018B

          teletext                 0x0184

          power                    0x0074

          1                        0x004F

          2                        0x0050

          3                        0x0051

          4                        0x004B

          5                        0x004C

          6                        0x004D

          7                        0x0047

          8                        0x0048

          9                        0x0049

          audio                    0x0188

          fullscreen               0x0174

          enter/0                  0x0052

          display                  0x0189

          loop                     0x00D9

          preview                  0x0166

          backward                 0x00A8

          forward                  0x00D0

          capture                  0x00A7

          mute                     0x0071

          record                   0x00A7

          pause                    0x0077

          stop                     0x0080

          play                     0x00CF

          red                      0x018E

          blue                     0x018F

          volup                    0x0073

          voldown                  0x0072

          chanup                   0x0192

          chandown                 0x0193

          cancel                   0x0191

          ok                       0x0190

end codes

end remote
```

7) Now start lircd daemon: /etc/init.d/lircd start

8) Quick check of ps ensures we got the right command line options there:

```
# ps -ef | grep lircd

root     31306     1  0 23:09 ?        00:00:00 /usr/sbin/lircd -H dev/input -d /dev/input/event2
```

When you start lirc it seems to attach to the input device and capture all keypresses from it, meaning your remote is no longer emulating a keyboard. I.e. keypresses don't go to lirc AND emulate a keyboard, they do one or the other depending whether lircd is running.

9) Now run irw to test. Press buttons on the remote and see output. Hooray!

If irw or lircd gives you trouble try looking in /var/log/messages (or wherever syslog writes on your box).

10) For mythtv you will need to setup an lircrc in the ~mythtv/.mythtv directory (my mythtv runs as user 'mythtv'). If you configure myth properly it will pick up the remote settings from there and connect to lirc. If mythfrontend isn't finding your lircrc it will print a message in the first 20 lines or so of console output when you run it, saying basically that it "can't open ~mythtv/lircrc", or something like that.

My mythtv lircrc currently looks like this. The original version of it came to me courtesy of a kind person on the linux-dvb mailing list, but I have tweaked it a little and still am tweaking it from time to time.

```
# Channel Up

begin

prog = mythtv

button = chanup

repeat = 3

config = Up

end

# Channel Down

begin

prog = mythtv

button = chandown

repeat = 3

config = Down

end

# OK/Select

begin

prog = mythtv

button = yellow

config = Space

end

# OK/Select

begin

prog = mythtv

button = ok

config = Space

end

# Play

begin

prog = mythtv

button = Play

config = Return

end

# Stop

begin

prog = mythtv

button = Stop

config = Esc

end

# Escape/Exit/Back

begin

prog = mythtv

button = cancel

config = Esc

end

# Power Off/Exit

begin

prog = mythtv

button = Power

config = Esc

end

# Red means stop!

begin

prog = mythtv

button = RED

config = Esc

end

# Pause

begin

prog = mythtv

button = Pause

repeat = 3

config = P

end

# Volume down

begin

prog = mythtv

button = voldown

repeat = 3

config = [

end

begin

prog = mythtv

button = volup

repeat = 3

config = ]

end

# Mute

begin

prog = mythtv

button = mute

repeat = 3

config = F9

end

# Fast forward (30 sec default)

begin

prog = mythtv

button = backward

repeat = 3

config = Left

end

# Rewind (10 sec default)

begin

prog = mythtv

button = forward

repeat = 3

config = Right

end

# Skip forward (10 min default)

begin

prog = mythtv

button = SKIP

repeat = 3

config = PgDown

end

# Skip backward (10 min default)

begin

prog = mythtv

button = REPLAY

repeat = 3

config = PgUp

end

# Record

begin

prog = mythtv

button = record

repeat = 3

config = R

end

# Delete

begin

prog = mythtv

button = BLANK

repeat = 3

config = D

end

# OSD browse

begin

prog = mythtv

button = green

repeat = 3

config = O

end

# Display EPG while in live TV,

# View selected show while in EPG

begin

prog = mythtv

button = display

repeat = 3

config = M

end

# Scroll up

begin

prog = mythtv

button = 6

repeat = 3

config = Right

end

# Scroll down

begin

prog = mythtv

button = 4

repeat = 3

config = Left

end

# Bring up OSD info

begin

prog = mythtv

button = source

repeat = 3

config = I

end

# Change display aspect ratio

begin

prog = mythtv

button = fullscreen

repeat = 3

config = W

end

# Seek to previous commercial cut point

begin

prog = mythtv

button = yellow

repeat = 3

config = Q

end

# Seek to next commercial cut point

begin

prog = mythtv

button = blue

repeat = 3

config = Z

end

# Numbers 0-9

begin

prog = mythtv

button = 0

repeat = 3

config = 0

end

begin

prog = mythtv

button = 1

repeat = 3

config = 1

end

begin

prog = mythtv

button = 2

repeat = 3

config = 2

end

begin

prog = mythtv

button = 3

repeat = 3

config = 3

end

begin

prog = mythtv

button = 4

repeat = 3

config = 4

end

begin

prog = mythtv

button = 5

repeat = 3

config = 5

end

begin

prog = mythtv

button = 6

repeat = 3

config = 6

end

begin

prog = mythtv

button = 7

repeat = 3

config = 7

end

begin

prog = mythtv

button = 8

repeat = 3

config = 8

end

begin

prog = mythtv

button = 9

repeat = 3

config = 9

end

```

----------

