New driver for Vlsys mplay (the one in Zalman Hd135 case)

View: New views
7 Messages — Rating Filter:   Alert me  

New driver for Vlsys mplay (the one in Zalman Hd135 case)

by ben905 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 
 In case anyone is interested, I've written a lirc driver for the receiver
that
 come with the Zalman Hd135 which appears to be a Vlsys Mplay Blast.
 I join the driver and a patch for lirc-0.8.2 (configure.in,
daemons/Makefile.am
 and daemons/hw-types.c) and my lircd.conf for this remote.
 I don't know how to add my driver to the lirc configuration interface. If any
 body can explain it to me, I will do it with pleasure.
 
 I hope this helps someone out,
 Benoit

# Please make this file available to others
# by sending it to <lirc@...>
#
# this config file was automatically generated
# using lirc-0.8.2(mplay) on Fri Dec  7 20:04:59 2007
#
# contributed by
#
# brand:                       /etc/lircd.conf
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  /etc/lircd.conf
  bits            8
  eps            30
  aeps          100

  one             0     0
  zero            0     0
  gap          211938
  toggle_bit_mask 0x0

      begin codes
          PwrOff                   0x41
          PwrOn                    0x55
          Movies                   0x40
          Television               0x46
          Pictures                 0x45
          Music                    0x56
          1                        0x4d
          2                        0x4e
          3                        0x4f
          4                        0x50
          5                        0x51
          6                        0x52
          7                        0x53
          8                        0x03
          9                        0x07
          0                        0x4c
          Vol+                     0x0a
          Vol-                     0x0e
          Ch+_Lang                 0x12
          Ch-_Page                 0x16
          Guide                    0x0f
          Back                     0x0b
          Tv                       0x13
          Ok                       0x42
          Up                       0x19
          Left                     0x54
          Right                    0x43
          Down                     0x1d
          Exit_Click               0x1f
          Task_Quick               0x17
          Run_DClick               0x1b
          Rew                      0x0d
          Play                     0x09
          Ffwd                     0x15
          Prev                     0x1a
          Stop                     0x01
          Next                     0x1e
          Pause                    0x05
          Mute                     0x4a
          Warp_Mouse               0x47
          Rec                      0x11
          DVD_Zoom                 0x14
          Detail                   0x4b
      end codes

end remote

---------------

/****************************************************************************
 ** hw_mplay.h ************************************************************
 ****************************************************************************
 *
 * LIRC driver for Vlsys mplay usb ftdi serial port remote control.
 *
 * Author: Benoit Laurent <ben905@...>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef _HW_MPLAY_H
#define _HW_MPLAY_H

#include "drivers/lirc.h"

extern int mplay_decode(struct ir_remote *remote,
                        ir_code *prep,
                        ir_code *codep,
                        ir_code *postp,
                        int *repeat_flagp,
                        lirc_t *remaining_gapp);

//int mplay_open_serial_port(char *device);
extern int mplay_init(void);
extern int mplay_deinit(void);
extern char *mplay_rec(struct ir_remote *remotes);

#endif

----------

/****************************************************************************
 ** hw_mplay.c **************************************************************
 ****************************************************************************
 *
 * LIRC driver for Vlsys mplay usb ftdi serial port remote control.
 *
 * Driver inspire from hw_accent et hw_alsa_usb.
 *
 * Copyright (c) 2007 Benoit Laurent <ben905@...>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/* Functions available for logging (see tools/lircrcd.c).
 *
 * NOTE: if compiled without the DEBUG option and with SYSLOG,
 * you cannot control the amount of debug info sent to syslog,
 * even the LOG_DEBUG messages will be logged.
 *
 * void logprintf(int priority, char *format, ...)
 *     Calls the syslog(3) function.
 *
 * void logperror(int priority, char *s)
 *    Uses the syslog(3) to print a message followed by the error message
 *    strerror (%m) associated to the present errno.
 *
 * void LOGPRINTF(int priority, char *format, ...)
 *    Calls logprintf(), but only if compiled with DEBUG option.
 *
 * void LOGPERROR(int priority, char *s)
 *    Calls logperror(), but only if compiled with DEBUG option.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <termios.h>

#include "lircd.h"
#include "hardware.h"
#include "serial.h"

#include "hw_mplay.h"

// The mplay code length in bit
#define MPLAY_CODE_LENGTH 8

// Code value send by the mplay to indicate a repeatition of the last code
#define MPLAY_REPEAT_CODE 0x7e

// Mplay serial baud rate
#define MPLAY_BAUD_RATE 38400

//-------------------------------------------------------------------------
// Definition of local struct that permit to save data from call to call
// of the driver.
//-------------------------------------------------------------------------
static struct {
    // the last receive code
    ir_code rc_code;
    // Int wich indicate that the last reception was a repetition
    int repeat_flag;
} mplay_local_data = {
    0,
    0
};

//-------------------------------------------------------------------------
// Definition of the standard internal hardware interface
// use by lirc for the mplay device
//-------------------------------------------------------------------------
struct hardware hw_mplay = {
    LIRC_DRIVER_DEVICE,     /* default device */
    -1,                     /* fd */
    LIRC_CAN_REC_CODE,      /* features */
    0,                      /* send_mode */
    LIRC_MODE_CODE,         /* rec_mode */
    MPLAY_CODE_LENGTH,      /* code_length */
    mplay_init,             /* init_func */
    NULL,                   /* config_func */
    mplay_deinit,           /* deinit_func */
    NULL,                   /* send_func */
    mplay_rec,              /* rec_func */
    mplay_decode,           /* decode_func */
    NULL,                   /* ioctl_func */
    NULL,                   /* readdata */
    "mplay"
};

//-------------------------------------------------------------------------
// Lock and initialize the serial port.
// This function is called by the LIRC daemon when the first client
// registers itself.
// Return 1 on success, 0 on error.
//-------------------------------------------------------------------------
int mplay_init(void)
{
    int result = 1;
    LOGPRINTF(LOG_DEBUG, "Entering mplay_init()");
    // Creation of a lock file for the port
    if (!tty_create_lock(hw.device)) {
        logprintf(LOG_ERR,   "Could not create the lock file");
        LOGPRINTF(LOG_EMERG, "Could not create the lock file");
        result = 0;
    }
    // Try to open serial port
    else if ((hw.fd = open (hw.device, O_RDWR | O_NONBLOCK | O_NOCTTY)) < 0) {
        logprintf(LOG_ERR,   "Could not open the serial port");
        LOGPRINTF(LOG_EMERG, "Could not open the serial port");
        mplay_deinit();
        result = 0;
    }
    // Serial port configuration
    else if (!tty_reset(hw.fd) || !tty_setbaud(hw.fd, MPLAY_BAUD_RATE))
    {
        logprintf(LOG_ERR,   "could not configure the serial port for "
            "'%s'", hw.device);
        LOGPRINTF(LOG_EMERG, "could not configure the serial port for "
            "'%s'", hw.device);
        mplay_deinit();
    }
    return(result);
}

//-------------------------------------------------------------------------
// Close and release the serial line.
//-------------------------------------------------------------------------
int mplay_deinit(void)
{
    LOGPRINTF(LOG_DEBUG, "Entering mplay_deinit()");
    close(hw.fd);
    tty_delete_lock();
    return(1);
}

//-------------------------------------------------------------------------
// Receive a code (1 byte) from the remote.
// This function is called by the LIRC daemon when I/O is pending
// from a registered client, e.g. irw.
//
// return ???????
//-------------------------------------------------------------------------
char *mplay_rec(struct ir_remote *remotes)
{
    unsigned char rc_code;
    LOGPRINTF(LOG_DEBUG, "Entering mplay_rec()");
    if (read(hw.fd, &rc_code, 1) == -1)
    {
        return NULL;
    }
    else
    {
        if (rc_code == MPLAY_REPEAT_CODE)
        {
            // This reception is a repeat
            mplay_local_data.repeat_flag = 1;
        }
        else
        {
            // This is a new code
            mplay_local_data.rc_code = rc_code;
            mplay_local_data.repeat_flag = 0;
        }
        LOGPRINTF(1, "code: %u", (unsigned int) mplay_local_data.rc_code);
        LOGPRINTF(1, "repeat_flag: %d", mplay_local_data.repeat_flag);
        return decode_all(remotes);
    }
}

//-------------------------------------------------------------------------
// This function is called by the LIRC daemon during the transform of a
// received code into an lirc event.
//
// It gets the global variable code (remote keypress code).
//
// It returns:
// prep Code prefix (zero for this LIRC driver)
//  codep Code of keypress
// postp Trailing code (zero for this LIRC dirver)
//  repeat_flagp True if the keypress is a repeated keypress
//  remaining_gapp Extimated time gap remaining before next code?
//-------------------------------------------------------------------------
int mplay_decode(
    struct ir_remote *remote,
    ir_code *prep,
    ir_code *codep,
    ir_code *postp,
    int *repeat_flagp,
    lirc_t *remaining_gapp)
{
    LOGPRINTF(LOG_DEBUG, "Entering mplay_decode(), code = %u\n",
        (unsigned int)mplay_local_data.rc_code);

    if(!map_code(
        remote,
        prep,
        codep,
        postp,
        0,
        0,
        MPLAY_CODE_LENGTH,
        mplay_local_data.rc_code,
        0, 0))
    {
        return(0);
    }
    *repeat_flagp = mplay_local_data.repeat_flag;
    *remaining_gapp = 0;
    return 1;
}

------------

--- lirc-0.8.2-original/configure.in 2007-06-09 20:54:09.000000000 +0200
+++ lirc-0.8.2/configure.in 2007-12-07 16:52:24.000000000 +0100
@@ -145,6 +145,7 @@
  (mediafocusI) \
  (mouseremote) \
  (mouseremote_ps2) \
+ (mplay) \
  (mp3anywhere) \
  (pcmak) \
  (pcmak_usb) \
@@ -274,7 +275,7 @@
                           leadtek_0007, leadtek_0010, leadtek_pvr2000,
                           livedrive_midi, livedrive_seq, logitech,
                           lptX, macmini, mceusb, mceusb2, mediafocusI,
-                          mouseremote, mouseremote_ps2, mp3anywhere,
+                          mouseremote, mouseremote_ps2, mplay, mp3anywhere,
                           nslu2,packard_bell, parallel, pcmak,
                           pcmak_usb, pctv, pixelview_bt878,
                           pixelview_pak, pixelview_pro, provideo,
@@ -443,6 +444,9 @@
  mouseremote_ps2)
  hw_module="${hw_module} hw_mouseremote.o serial.o"
  ;;
+ mplay)
+ hw_module="${hw_module} hw_mplay.o serial.o"
+ ;;
  mp3anywhere)
  hw_module="${hw_module} hw_mp3anywhere.o serial.o"
  ;;
@@ -936,6 +940,13 @@
   lircmd_conf="x10/lircmd.conf.mouseremote"
 fi
 
+if test "$driver" = "mplay"; then
+  lirc_driver="none"
+  hw_module="hw_mplay.o serial.o"
+  HW_DEFAULT="hw_mplay"
+#  lircd_conf="x10/lircd.conf.mp3anywhere"
+fi
+
 if test "$driver" = "mp3anywhere"; then
   lirc_driver="none"
   hw_module="hw_mp3anywhere.o serial.o"
--- lirc-0.8.2-original/daemons/Makefile.am 2007-05-06 11:46:59.000000000
+0200
+++ lirc-0.8.2/daemons/Makefile.am 2007-12-07 16:25:59.000000000 +0100
@@ -36,6 +36,7 @@
  hw_livedrive_midi.c hw_livedrive_seq.c \
  hw_logitech.c hw_logitech.h \
  hw_mouseremote.c hw_mouseremote.h \
+ hw_mplay.c hw_mplay.h \
  hw_mp3anywhere.c hw_mp3anywhere.h \
  hw_pcmak.c hw_pcmak.h \
  hw_pinsys.c hw_pinsys.h \
@@ -84,6 +85,7 @@
  hw_livedrive_midi.c hw_livedrive_seq.c \
  hw_logitech.c hw_logitech.h \
  hw_mouseremote.c hw_mouseremote.h \
+ hw_mplay.c hw_mplay.h \
  hw_mp3anywhere.c hw_mp3anywhere.h \
  hw_pcmak.c hw_pcmak.h \
  hw_pinsys.c hw_pinsys.h \
--- lirc-0.8.2-original/daemons/hw-types.c 2007-05-05 14:20:03.000000000 +0200
+++ lirc-0.8.2/daemons/hw-types.c 2007-12-07 15:49:46.000000000 +0100
@@ -7,6 +7,7 @@
 #include "hw-types.h"
 /* Hardware types */
 extern struct hardware hw_accent;
+extern struct hardware hw_mplay;
 extern struct hardware hw_alsa_usb;
 extern struct hardware hw_asusdh;
 extern struct hardware hw_atilibusb;
@@ -72,6 +73,7 @@
 {
 #ifdef LIRC_DRIVER_ANY
  &hw_accent,
+ &hw_mplay,
 #ifdef HAVE_ALSA_SB_RC
  &hw_alsa_usb,
 #endif

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

Re: New driver for Vlsys mplay (the one in Zalman Hd135 case)

by Christoph Bartelmus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Benoit Laurent "ben905@..." wrote:
>  In case anyone is interested, I've written a lirc driver for the receiver
> that
>  come with the Zalman Hd135 which appears to be a Vlsys Mplay Blast.
>  I join the driver and a patch for lirc-0.8.2 (configure.in,
> daemons/Makefile.am
>  and daemons/hw-types.c) and my lircd.conf for this remote.
>  I don't know how to add my driver to the lirc configuration interface. If
> any  body can explain it to me, I will do it with pleasure.

You just need to modify setup.data. autogen.sh will create everything  
requried.

Some comments regarding implementation:

- mplay_deinit: please reset hw.fd to -1

- mplay_rec: if the read fails, call mplay_deinit to close the device.  
This will prevent endless looping when the device is disconnected.

- please don't use C++ comments

- intendation should be 8

- mplay_decode: the interface has changed in latest CVS. Please update  
your code

Please attach your patch as a file next time instead of sending it  
inline in the message.

Christoph

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

Re: New driver for Vlsys mplay (the one in Zalman Hd135 case)

by ben905 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> You just need to modify setup.data. autogen.sh will create everything
> requried.
>
> Some comments regarding implementation:
>
> - mplay_deinit: please reset hw.fd to -1
>
> - mplay_rec: if the read fails, call mplay_deinit to close the device.
> This will prevent endless looping when the device is disconnected.
>
> - please don't use C++ comments
>
> - intendation should be 8
>
> - mplay_decode: the interface has changed in latest CVS. Please update
> your code
>
> Please attach your patch as a file next time instead of sending it
> inline in the message.
>
> Christoph
Christoph, I have modify what you want:
 - reset hw.fd in deinit,
 - call deinit in rec if the read file,
 - use only C comments,
 - use an intendation of 8,
 - update the interface of mplay_decode.
I also do :
 - add information about how the device work,
 - add the driver to the configuration interface,
 - add some comment,
 - identify and resolve an issu with key repetition (see comment in .c file),
 - test the driver on my htpc during few days,
 - and test if the driver work well in collaboration with the new lcdproc
driver for the lcd integrated in the device.

The patch is for the cvs version of lirc.

Benoit



-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

mplay_driver_lirc_cvs.patch.bz2 (7K) Download Attachment

Re: New driver for Vlsys mplay (the one in Zalman Hd135 case)

by Christoph Bartelmus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Benoit Laurent "ben905@..." wrote:
> The patch is for the cvs version of lirc.

Applied. Thanks.

Christoph


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Re: New driver for Vlsys mplay (the one in Zalman Hd135 case)

by sum78 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm very interested in making IR-remote work, as well as in VFD to show information. I'm rather new with linux, could you please explain how to install/apply your driver. I'm using Ubuntu 7.10.

Thanx in advance

Oleg




Christoph Bartelmus wrote:
Hi!

Benoit Laurent "ben905@free.fr" wrote:
>  In case anyone is interested, I've written a lirc driver for the receiver
> that
>  come with the Zalman Hd135 which appears to be a Vlsys Mplay Blast.
>  I join the driver and a patch for lirc-0.8.2 (configure.in,
> daemons/Makefile.am
>  and daemons/hw-types.c) and my lircd.conf for this remote.
>  I don't know how to add my driver to the lirc configuration interface. If
> any  body can explain it to me, I will do it with pleasure.

You just need to modify setup.data. autogen.sh will create everything  
requried.

Some comments regarding implementation:

- mplay_deinit: please reset hw.fd to -1

- mplay_rec: if the read fails, call mplay_deinit to close the device.  
This will prevent endless looping when the device is disconnected.

- please don't use C++ comments

- intendation should be 8

- mplay_decode: the interface has changed in latest CVS. Please update  
your code

Please attach your patch as a file next time instead of sending it  
inline in the message.

Christoph

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

Re: New driver for Vlsys mplay (the one in Zalman Hd135 case)

by ben905 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Oleg,

There actually no released of lirc that integrate the mplay driver so you need
to use source form the cvs (or a cvs snapshot).

As user do :
cvs -d:pserver:anonymous@...:/cvsroot/lirc login
cvs -z8 -d:pserver:anonymous@...:/cvsroot/lirc co lirc
cd lirc
./autogen.sh
./setup.sh
  ->"Driver configuration"
    ->"USB devices"
      ->" Vlsys Mplay blast"
        -> choose the goog ttyUSB
next "Save configuration & run configure"
make
As root in the same directory:
make install
cp  ./remotes/vlsystem/lircd.conf.mplay /etc/lircd.conf
lircd -d /dev/ttyUSBX (replace X with the good tty number)
irw
Now press key on you remote and you will see her name appear. If it's the case
your remote work and you now need to configure your application to use it via
lirc.

I hope that will help you and good luck!
Ben.

Le Tuesday 05 February 2008 08:09:33 sum78, vous avez écrit :
> Hi,
>
> I'm very interested in making IR-remote work, as well as in VFD to show
> information. I'm rather new with linux, could you please explain how to
> install/apply your driver. I'm using Ubuntu 7.10.
>
> Thanx in advance
>
> Oleg

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Re: New driver for Vlsys mplay (the one in Zalman Hd135 case)

by sum78 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you so much! I will try it soon!