File: geniusvp2-asic.c

package info (click to toggle)
sane-backends-extras 1.0.22.4
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 3,080 kB
  • ctags: 2,710
  • sloc: ansic: 27,680; sh: 10,433; makefile: 448
file content (98 lines) | stat: -rw-r--r-- 2,620 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* asic.c - ASIC registers I/O functions
 * 
 * Copyright (C) 2004, 2005 Anderson Lizardo
 *
 * 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
*/

#ifdef __linux__
#  include <linux/parport.h>
#endif

#include "geniusvp2-asic.h"
#include "geniusvp2-parport.h"

int
sane_geniusvp2_reg_read (unsigned char reg, unsigned char *data)
{
    return sane_geniusvp2_reg_read_buf (reg, data, 1);
}

int
sane_geniusvp2_reg_read_buf (unsigned char reg, unsigned char *data, size_t size)
{
#ifdef __linux__
    sane_geniusvp2_epp_set_mode (IEEE1284_ADDR);
    sane_geniusvp2_epp_write (&reg, 1);
    sane_geniusvp2_epp_set_mode (IEEE1284_DATA);
#elif defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
    sane_geniusvp2_epp_write_addr (reg);
#endif
    return sane_geniusvp2_epp_read (data, size);
}

int
sane_geniusvp2_reg_write (unsigned char reg, unsigned char data)
{
    return sane_geniusvp2_reg_write_buf (reg, &data, 1);
}

int
sane_geniusvp2_reg_write_buf (unsigned char reg, unsigned char *data, size_t size)
{
#ifdef __linux__
    sane_geniusvp2_epp_set_mode (IEEE1284_ADDR);
    sane_geniusvp2_epp_write (&reg, 1);
    sane_geniusvp2_epp_set_mode (IEEE1284_DATA);
#elif defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
    sane_geniusvp2_epp_write_addr (reg);
#endif
    return sane_geniusvp2_epp_write (data, size);
}

void
sane_geniusvp2_init_regs (void)
{
    reg0.w = 0xe1;
    reg1.w = 0x5a;
    reg2.w = 0x00;
    reg3.w = 0x0f;
    reg4.w = 0x32;
    reg5.w = 0x00;
    reg6.w = 0x94;
    reg7.w = 0x09;
    reg8.w = 0xc4;
    reg9.w = 0x0a;
    reg10.w = 0x17;
    reg11.w = 0x70;
    reg12.w = 0x44;
    reg13.w = 0x91;
    reg14.w = 0x07;
    reg15.w = 0xff;
    reg16.w = 0xff;
    reg17.w = 0x00;
    reg18.w = 0x00;
    reg19.w = 0x00;
    reg20.w = 0x00;
    reg21.w = 0x00;
    reg22.w = 0x13;
    reg23.w = 0xec;
    reg24.w = 0x86;
    reg25.w = 0xf0;
    reg26.w = 0x18;
    reg27.w = 0x22;
    reg28.w = 0x58;
    reg29.w = 0x58;
}