1141cc406Sopenharmony_ci/* sane - Scanner Access Now Easy. 2141cc406Sopenharmony_ci Copyright (C) 2000-2003 Jochen Eisinger <jochen.eisinger@gmx.net> 3141cc406Sopenharmony_ci This file is part of the SANE package. 4141cc406Sopenharmony_ci 5141cc406Sopenharmony_ci This program is free software; you can redistribute it and/or 6141cc406Sopenharmony_ci modify it under the terms of the GNU General Public License as 7141cc406Sopenharmony_ci published by the Free Software Foundation; either version 2 of the 8141cc406Sopenharmony_ci License, or (at your option) any later version. 9141cc406Sopenharmony_ci 10141cc406Sopenharmony_ci This program is distributed in the hope that it will be useful, but 11141cc406Sopenharmony_ci WITHOUT ANY WARRANTY; without even the implied warranty of 12141cc406Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13141cc406Sopenharmony_ci General Public License for more details. 14141cc406Sopenharmony_ci 15141cc406Sopenharmony_ci You should have received a copy of the GNU General Public License 16141cc406Sopenharmony_ci along with this program. If not, see <https://www.gnu.org/licenses/>. 17141cc406Sopenharmony_ci 18141cc406Sopenharmony_ci As a special exception, the authors of SANE give permission for 19141cc406Sopenharmony_ci additional uses of the libraries contained in this release of SANE. 20141cc406Sopenharmony_ci 21141cc406Sopenharmony_ci The exception is that, if you link a SANE library with other files 22141cc406Sopenharmony_ci to produce an executable, this does not by itself cause the 23141cc406Sopenharmony_ci resulting executable to be covered by the GNU General Public 24141cc406Sopenharmony_ci License. Your use of that executable is in no way restricted on 25141cc406Sopenharmony_ci account of linking the SANE library code into it. 26141cc406Sopenharmony_ci 27141cc406Sopenharmony_ci This exception does not, however, invalidate any other reasons why 28141cc406Sopenharmony_ci the executable file might be covered by the GNU General Public 29141cc406Sopenharmony_ci License. 30141cc406Sopenharmony_ci 31141cc406Sopenharmony_ci If you submit changes to SANE to the maintainers to be included in 32141cc406Sopenharmony_ci a subsequent release, you agree by submitting the changes that 33141cc406Sopenharmony_ci those changes may be distributed with this exception intact. 34141cc406Sopenharmony_ci 35141cc406Sopenharmony_ci If you write modifications of your own for SANE, it is your choice 36141cc406Sopenharmony_ci whether to permit this exception to apply to your modifications. 37141cc406Sopenharmony_ci If you do not wish that, delete this exception notice. 38141cc406Sopenharmony_ci 39141cc406Sopenharmony_ci This file implements a SANE backend for Mustek PP flatbed scanners. */ 40141cc406Sopenharmony_ci 41141cc406Sopenharmony_ci#include "../include/sane/config.h" 42141cc406Sopenharmony_ci 43141cc406Sopenharmony_ci#if defined(HAVE_STDLIB_H) 44141cc406Sopenharmony_ci# include <stdlib.h> 45141cc406Sopenharmony_ci#endif 46141cc406Sopenharmony_ci#include <ctype.h> 47141cc406Sopenharmony_ci#include <stdio.h> 48141cc406Sopenharmony_ci#if defined(HAVE_STRING_H) 49141cc406Sopenharmony_ci# include <string.h> 50141cc406Sopenharmony_ci#elif defined(HAVE_STRINGS_H) 51141cc406Sopenharmony_ci# include <strings.h> 52141cc406Sopenharmony_ci#endif 53141cc406Sopenharmony_ci 54141cc406Sopenharmony_ci#define DEBUG_DECLARE_ONLY 55141cc406Sopenharmony_ci 56141cc406Sopenharmony_ci#include "mustek_pp.h" 57141cc406Sopenharmony_ci#include "mustek_pp_decl.h" 58141cc406Sopenharmony_ci#include "../include/sane/sane.h" 59141cc406Sopenharmony_ci#include "../include/sane/sanei.h" 60141cc406Sopenharmony_ci 61141cc406Sopenharmony_ci#define MUSTEK_PP_NULL_DRIVER 0 62141cc406Sopenharmony_ci 63141cc406Sopenharmony_cistatic SANE_Status 64141cc406Sopenharmony_cidebug_drv_init(SANE_Int options, SANE_String_Const port, 65141cc406Sopenharmony_ci SANE_String_Const name, SANE_Attach_Callback attach) 66141cc406Sopenharmony_ci{ 67141cc406Sopenharmony_ci 68141cc406Sopenharmony_ci if (options != CAP_NOTHING) 69141cc406Sopenharmony_ci return SANE_STATUS_INVAL; 70141cc406Sopenharmony_ci 71141cc406Sopenharmony_ci return attach(port, name, MUSTEK_PP_NULL_DRIVER, 0); 72141cc406Sopenharmony_ci 73141cc406Sopenharmony_ci} 74141cc406Sopenharmony_ci 75141cc406Sopenharmony_ci/*ARGSUSED*/ 76141cc406Sopenharmony_cistatic void 77141cc406Sopenharmony_cidebug_drv_capabilities(SANE_Int info __UNUSED__, SANE_String *model, 78141cc406Sopenharmony_ci SANE_String *vendor, SANE_String *type, 79141cc406Sopenharmony_ci SANE_Int *maxres, SANE_Int *minres, 80141cc406Sopenharmony_ci SANE_Int *maxhsize, SANE_Int *maxvsize, 81141cc406Sopenharmony_ci SANE_Int *caps) 82141cc406Sopenharmony_ci{ 83141cc406Sopenharmony_ci 84141cc406Sopenharmony_ci *model = strdup("debugger"); 85141cc406Sopenharmony_ci *vendor = strdup("mustek_pp"); 86141cc406Sopenharmony_ci *type = strdup("software emulated"); 87141cc406Sopenharmony_ci *maxres = 300; 88141cc406Sopenharmony_ci *minres = 50; 89141cc406Sopenharmony_ci *maxhsize = 1000; 90141cc406Sopenharmony_ci *maxvsize = 3000; 91141cc406Sopenharmony_ci *caps = CAP_NOTHING; 92141cc406Sopenharmony_ci 93141cc406Sopenharmony_ci} 94141cc406Sopenharmony_ci 95141cc406Sopenharmony_ci/*ARGSUSED*/ 96141cc406Sopenharmony_cistatic SANE_Status 97141cc406Sopenharmony_cidebug_drv_open (SANE_String port __UNUSED__, 98141cc406Sopenharmony_ci SANE_Int caps __UNUSED__, SANE_Int *fd) 99141cc406Sopenharmony_ci{ 100141cc406Sopenharmony_ci *fd = 1; 101141cc406Sopenharmony_ci return SANE_STATUS_GOOD; 102141cc406Sopenharmony_ci} 103141cc406Sopenharmony_ci 104141cc406Sopenharmony_cistatic void 105141cc406Sopenharmony_cidebug_drv_setup (SANE_Handle hndl) 106141cc406Sopenharmony_ci{ 107141cc406Sopenharmony_ci 108141cc406Sopenharmony_ci Mustek_pp_Handle *dev = hndl; 109141cc406Sopenharmony_ci 110141cc406Sopenharmony_ci dev->lamp_on = 0; 111141cc406Sopenharmony_ci dev->priv = NULL; 112141cc406Sopenharmony_ci} 113141cc406Sopenharmony_ci 114141cc406Sopenharmony_ci/*ARGSUSED*/ 115141cc406Sopenharmony_cistatic SANE_Status 116141cc406Sopenharmony_cidebug_drv_config(SANE_Handle hndl __UNUSED__, 117141cc406Sopenharmony_ci SANE_String_Const optname, 118141cc406Sopenharmony_ci SANE_String_Const optval) 119141cc406Sopenharmony_ci{ 120141cc406Sopenharmony_ci DBG (3, "debug_drv cfg option: %s=%s\n", optname, optval ? optval : ""); 121141cc406Sopenharmony_ci return SANE_STATUS_GOOD; 122141cc406Sopenharmony_ci} 123141cc406Sopenharmony_ci 124141cc406Sopenharmony_ci/*ARGSUSED*/ 125141cc406Sopenharmony_cistatic void 126141cc406Sopenharmony_cidebug_drv_close (SANE_Handle hndl __UNUSED__) 127141cc406Sopenharmony_ci{ 128141cc406Sopenharmony_ci} 129141cc406Sopenharmony_ci 130141cc406Sopenharmony_ci/*ARGSUSED*/ 131141cc406Sopenharmony_cistatic SANE_Status 132141cc406Sopenharmony_cidebug_drv_start (SANE_Handle hndl __UNUSED__) 133141cc406Sopenharmony_ci{ 134141cc406Sopenharmony_ci return SANE_STATUS_GOOD; 135141cc406Sopenharmony_ci} 136141cc406Sopenharmony_ci 137141cc406Sopenharmony_cistatic void 138141cc406Sopenharmony_cidebug_drv_read (SANE_Handle hndl, SANE_Byte *buffer) 139141cc406Sopenharmony_ci{ 140141cc406Sopenharmony_ci 141141cc406Sopenharmony_ci Mustek_pp_Handle *dev = hndl; 142141cc406Sopenharmony_ci 143141cc406Sopenharmony_ci memset (buffer, 0, dev->params.bytes_per_line); 144141cc406Sopenharmony_ci} 145141cc406Sopenharmony_ci 146141cc406Sopenharmony_ci/*ARGSUSED*/ 147141cc406Sopenharmony_cistatic void 148141cc406Sopenharmony_cidebug_drv_stop (SANE_Handle hndl __UNUSED__) 149141cc406Sopenharmony_ci{ 150141cc406Sopenharmony_ci 151141cc406Sopenharmony_ci} 152