summaryrefslogtreecommitdiffstats
path: root/klaptopdaemon/kpcmcia.h
blob: 489d3e82dd619e207a7d089dfd7fea638bda8ff3 (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/* This file is part of the KDE project
 *
 * Copyright (C) 2001 George Staikos <staikos@kde.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */ 


#ifndef _KPCMCIA_H
#define _KPCMCIA_H

class TQTimer;
class KPCMCIA;

#include <tqmemarray.h>

#include <sys/types.h>

#define CARD_STATUS_PRESENT    1
#define CARD_STATUS_READY      2
#define CARD_STATUS_BUSY       4
#define CARD_STATUS_SUSPEND    8
#define CARD_STATUS_SUSPENDED  8


class KPCMCIACard {
friend class KPCMCIA;
protected:
   KPCMCIACard();
   ~KPCMCIACard();

   int _fd;

   int _interrupt;
   TQString _device, _ports;
   TQString _module;
   TQString _cardname;
   TQString _type;
   int _vcc, _vpp, _vpp2;
   TQString _stabPath;
   int _iotype;
   int _inttype;
   int _cfgbase;

   int _status;
   int _num;

   // Other fields for the future
   //  etc look in linux/cs.h for more info

public:

   /**
    *    Base address for configuration
    */
   inline int configBase() { return _cfgbase; }

   /**
    *    Interrupt type
    */
   inline int intType() { return _inttype; }

   /**
    *    16/32 bit
    */
   inline int busWidth() { return _iotype; }

   /**
    *    True if the card is present
    */
   inline bool present() { return _status & CARD_STATUS_PRESENT; }

   /**
    *    Return the card status
    */
   inline int status() { return _status; }

   /**
    *    Request to eject the card
    */
   int eject();

   /**
    *    Request to resume from suspend
    */
   int resume();

   /**
    *    Request to suspend
    */
   int suspend();

   /**
    *    Request to reset the card
    */
   int reset();

   /**
    *    Insert a card   (mostly not needed?)
    */
   int insert();

   /**
    *    Return the card number
    */
   inline int num() { return _num; }

   /**
    *    Return the interrupt in use (or -1 if none)
    */
   inline int irq() { return _interrupt; }

   /**
    *    Return the VCC status
    */
   inline int vcc() { return _vcc; }

   /**
    *    Return the card programming power (1)
    */
   inline int vpp() { return _vpp; }

   /**
    *    Return the card programming power (2)
    */
   inline int vpp2() { return _vpp2; }

   /**
    *    Return the card name
    */
   inline TQString& name() { return _cardname; }

   /**
    *    Return the port range
    */
   inline TQString& ports() { return _ports; }

   /**
    *    Return the device name
    */
   inline TQString& device() { return _device; }

   /**
    *    Return the device type  (ie network, modem, etc)
    */
   inline TQString& type() { return _type; }

   /**
    *    Return the driver (module) name
    */
   inline TQString& driver() { return _module; }

   /**
    *    Refresh the card information - return < 0 on error.
    *    (this is called automatically [by KPCMCIA] on a timer normally)
    */
   int refresh();

private:
   time_t _last;
};




class KPCMCIA : public TQObject {
  Q_OBJECT
  TQ_OBJECT
public:

  KPCMCIA(int maxSlots = 8, const char *stabPath = "/var/run/stab");
  ~KPCMCIA();

  void setRefreshSpeed(int msec);
  int getCardCount();
  KPCMCIACard *getCard(int num);

  bool haveCardServices();

signals:
  void cardUpdated(int num);


public slots:
  void updateCardInfo();

private:
  int _refreshSpeed;
  TQTimer *_timer;
  TQMemArray<KPCMCIACard *> *_cards;
  int _cardCnt;
  bool _haveCardServices;
  int _maxSlots;
  TQString _stabPath;
  
};




#endif