GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take a/* $Id$
* $URL$
*
* new style driver for USBLCD displays
*
* Copyright (C) 2003 Michael Reinelt <reinelt@eunet.at>
* Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* based on the old-style USBLCD driver which is
* Copyright (C) 2002 Robin Adams, Adams IT Services <info@usblcd.de>
*
* This file is part of LCD4Linux.
*
* LCD4Linux 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, or (at your option)
* any later version.
*
* LCD4Linux 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/*
*
* exported fuctions:
*
* struct DRIVER drv_USBLCD
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#ifdef HAVE_USB_H
#include <usb.h>
#endif
#include "debug.h"
#include "cfg.h"
#include "qprintf.h"
#include "udelay.h"
#include "plugin.h"
#include "widget.h"
#include "widget_text.h"
#include "widget_icon.h"
#include "widget_bar.h"
#include "drv.h"
#include "drv_generic_text.h"
#define USBLCD_VENDOR 0x10D2
#define USBLCD_VENDOR2 0x1212
#define USBLCD_DEVICE 0x0001
#define IOC_GET_HARD_VERSION 1
#define IOC_GET_DRV_VERSION 2
static char Name[] = "USBLCD";
static char *Port = NULL;
static int use_libusb = 0;
static int usblcd_file;
static char *Buffer;
static char *BufPtr;
#ifdef HAVE_USB_H
static usb_dev_handle *lcd;
static int interface;
extern int usb_debug;
#endif
/****************************************/
/*** hardware dependant functions ***/
/****************************************/
#ifdef HAVE_USB_H
static int drv_UL_open(void)
{
struct usb_bus *busses, *bus;
struct usb_device *dev;
lcd = NULL;
info("%s: scanning for USBLCD...", Name);
usb_debug = 0;
usb_init();
usb_find_busses();
usb_find_devices();
busses = usb_get_busses();
for (bus = busses; bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {
if (((dev->descriptor.idVendor == USBLCD_VENDOR) ||
(dev->descriptor.idVendor == USBLCD_VENDOR2)) && (dev->descriptor.idProduct == USBLCD_DEVICE)) {
unsigned int v = dev->descriptor.bcdDevice;
info("%s: found USBLCD V%1d%1d.%1d%1d on bus %s device %s", Name,
(v & 0xF000) >> 12, (v & 0xF00) >> 8, (v &