Big clean up of Video for Linux backend. Removed old unused stuff from qcam

and others including unused options and variables concerning direct port
access. Removed wcam license (no "substantial portions of code" are used any
more). Removed unuesed headers. Made lots of global variables local. Lots of
checks for null pointer dereferences and errors when opening files or using
ioctl/mmap. Added option to select grey or color mode. Added support for
different channels. Fixed lots of options.  Made sure ioctls are only used
when necessary.  Used vendor == "Noname".  Added ??? comments for suspicious
code.  Lots of minor fixes and cleanup. Added version number: 1.0-2.
DEVEL_2_0_BRANCH-1
Henning Geinitz 2002-08-29 19:34:53 +00:00
rodzic d054ded6c1
commit 8b0a038f61
3 zmienionych plików z 557 dodań i 629 usunięć

Plik diff jest za duży Load Diff

Wyświetl plik

@ -1,5 +1,7 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 David Mosberger-Tang
Updates and bugfixes (C) 2002 Henning Meier-Geinitz
This file is part of the SANE package.
As a special exception, the authors of SANE give permission for
@ -22,42 +24,13 @@
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice.
Portions of this code are derived from Scott Laird's qcam driver.
It's copyright notice is reproduced here:
Copyright (C) 1996 by Scott Laird
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL SCOTT LAIRD BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
*/
#ifndef v4l_h
#define v4l_h
#include <../include/sane/sane.h>
typedef enum
{
V4L_MONO = 0x01,
V4L_COLOR = 0x10
}
V4L_Model;
#define MAX_CHANNELS 32
typedef enum
{
@ -66,52 +39,13 @@ typedef enum
}
V4L_Resolution;
/* commands common to all quick-cameras: */
typedef enum
{
V4L_SEND_VIDEO_FRAME = 7,
V4L_SET_BRIGHTNESS = 11,
V4L_SET_TOP = 13,
V4L_SET_LEFT = 15,
V4L_SET_NUM_V = 17,
V4L_SET_NUM_H = 19,
V4L_SEND_VERSION = 23,
V4L_SET_BLACK = 29,
V4L_SET_WHITE = 31,
V4L_SET_SATURATION = 35,
V4L_SEND_STATUS = 41,
V4L_SET_SPEED = 45
}
V4L_Command;
/* commands for grayscale camera: */
typedef enum
{
V4L_MONO_SET_CONTRAST = 25,
V4L_MONO_AUTO_ADJUST_OFFSET = 27,
V4L_MONO_GET_OFFSET = 33
}
V4L_Mono_Command;
/* commands for color camera: */
typedef enum
{
V4L_COL_LOAD_RAM = 27,
V4L_COL_SET_HUE = 33,
V4L_COL_SET_CONTRAST = 37
}
V4L_Col_Command;
typedef enum
{
OPT_NUM_OPTS = 0,
OPT_MODE_GROUP,
OPT_DEPTH, /* 4 or 6 (b&w) or 24 (color) */
OPT_RESOLUTION, /* resolution in pixels */
OPT_XFER_SCALE, /* transfer-scale */
OPT_DESPECKLE, /* turn on despeckling? */
OPT_TEST, /* test image */
OPT_MODE,
OPT_CHANNEL,
OPT_GEOMETRY_GROUP,
OPT_TL_X, /* top-left x */
@ -121,11 +55,10 @@ typedef enum
OPT_ENHANCEMENT_GROUP,
OPT_BRIGHTNESS,
OPT_CONTRAST,
OPT_BLACK_LEVEL,
OPT_WHITE_LEVEL,
OPT_HUE,
OPT_SATURATION,
OPT_COLOR,
OPT_CONTRAST,
OPT_WHITE_LEVEL,
/* must come last: */
NUM_OPTIONS
@ -140,30 +73,10 @@ typedef union
}
Option_Value;
typedef enum
{
V4L_UNIDIR,
V4L_BIDIR
}
V4L_Port_Mode;
typedef struct
{
size_t num_bytes; /* # of bytes to read */
V4L_Resolution resolution; /* high-resolution? */
SANE_Parameters params; /* other parameters */
u_int mode; /* qcam scan code (get video data command) */
int despeckle; /* apply despeckling filter? */
}
V4L_Scan_Request;
typedef struct V4L_Device
{
struct V4L_Device *next;
SANE_Device sane;
V4L_Port_Mode port_mode;
int version; /* camera version */
int lock_fd; /* used for locking protocol */
}
V4L_Device;
@ -178,16 +91,19 @@ typedef struct V4L_Scanner
SANE_String_Const devicename; /* Name of the Device */
int fd; /* Filedescriptor */
SANE_Int user_corner; /* bitmask of user-selected coordinates */
SANE_Int value_changed; /* bitmask of options that were set */
SANE_Bool scanning;
SANE_Bool deliver_eof;
SANE_Bool mmap; /* Do we use mmap ? */
SANE_Bool is_mmap; /* Do we use mmap ? */
/* state for reading a frame: */
size_t num_bytes; /* # of bytes read so far */
size_t bytes_per_frame; /* total number of bytes in frame */
/* internal state for v4l_readbytes(): */
int readbytes_state;
unsigned int saved_bits;
struct video_capability capability;
struct video_picture pict;
struct video_window window;
struct video_mbuf mbuf;
struct video_mmap mmap;
SANE_String_Const channel[MAX_CHANNELS];
SANE_Int buffercount;
}
V4L_Scanner;

Wyświetl plik

@ -10,10 +10,10 @@
;
:backend "v4l" ; name of backend
:version "0.1" ; version of backend
:version "1.0-2" ; version of backend
:status :alpha ; :alpha, :beta, :stable, :new
:manpage "sane-v4l" ; name of manpage (if it exists)
;:url "http://www.franken.de/users/solid/" ; backend's web page
:url "mailto:henning@meier-geinitz.de" ; backend's web page
:devicetype :api ; start of a list of devices....
; other types: :stillcam, :vidcam,
@ -21,6 +21,6 @@
:desc "Interface to Video For Linux API" ; describe a non-hardware device
:comment "Supports video cameras and other devices accessed by the v4l kernel API, e.g. bttv devices."
; :comment and :url specifiers are optional after :mfg, :model, :desc,
; and at the top-level.