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
|
/*
*
* $Id: pvrusb2-hdw-internal.h,v 1.4 2006/01/01 08:26:03 mcisely Exp $
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
* 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
*
* 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
*
*/
#ifndef __PVRUSB2_HDW_INTERNAL_H
#define __PVRUSB2_HDW_INTERNAL_H
/*
This header sets up all the internal structures and definitions needed to
track and coordinate the driver's interaction with the hardware. ONLY
source files which actually implement part of that whole circus should be
including this header. Higher levels, like the external layers to the
various public APIs (V4L, sysfs, etc) should NOT ever include this
private, internal header. This means that pvrusb2-hdw, pvrusb2-encoder,
etc will include this, but pvrusb2-v4l should not.
*/
#include "compat.h"
#include <linux/videodev2.h>
#include <linux/i2c.h>
#include <asm/semaphore.h>
#include "pvrusb2-hdw.h"
#include "pvrusb2-io.h"
#define PVR2_VID_ENDPOINT 0x84
#define PVR2_UNK_ENDPOINT 0x86 /* maybe raw yuv ? */
#define PVR2_VBI_ENDPOINT 0x88
#define PVR2_CTL_BUFFSIZE 64
#define FREQTABLE_SIZE 500
#define LOCK_TAKE(x) do { down(&x##_sem); x##_held = !0; } while (0)
#define LOCK_GIVE(x) do { x##_held = 0; up(&x##_sem); } while (0)
struct pvr2_decoder;
struct pvr2_ctl_state {
int value;
int dirty;
};
struct pvr2_audio_stat {
void *ctxt;
void (*detach)(void *);
int (*status)(void *);
};
struct pvr2_decoder_ctrl {
void *ctxt;
void (*detach)(void *);
void (*enable)(void *,int);
int (*tuned)(void *);
};
#define PVR2_I2C_PEND_DETECT 0x01 /* Need to detect a client type */
#define PVR2_I2C_PEND_CLIENT 0x02 /* Client needs a specific update */
#define PVR2_I2C_PEND_REFRESH 0x04 /* Client has specific pending bits */
#define PVR2_I2C_PEND_STALE 0x08 /* Broadcast pending bits */
#define PVR2_I2C_PEND_ALL (PVR2_I2C_PEND_DETECT |\
PVR2_I2C_PEND_CLIENT |\
PVR2_I2C_PEND_REFRESH |\
PVR2_I2C_PEND_STALE)
/* This structure contains all state data directly needed to
manipulate the hardware (as opposed to complying with a kernel
interface) */
struct pvr2_hdw {
/* Underlying USB device handle */
struct usb_device *usb_dev;
struct usb_interface *usb_intf;
/* Video spigot */
struct pvr2_stream *vid_stream;
/* Mutex for all hardware state control */
struct semaphore big_lock_sem;
int big_lock_held; /* For debugging */
void (*poll_trigger_func)(void *);
void *poll_trigger_data;
char name[32];
/* I2C stuff */
struct i2c_adapter i2c_adap;
struct i2c_algorithm i2c_algo;
int i2c_linked;
unsigned int i2c_pend_types; /* Which types of update are needed */
unsigned long i2c_pend_mask; /* Change bits we need to scan */
unsigned long i2c_stale_mask; /* Pending broadcast change bits */
unsigned long i2c_active_mask; /* All change bits currently in use */
struct list_head i2c_clients;
struct semaphore i2c_list_lock;
/* Frequency table */
unsigned int freqTable[FREQTABLE_SIZE];
/* Stuff for handling low level control interaction with device */
struct semaphore ctl_lock_sem;
int ctl_lock_held; /* For debugging */
struct urb *ctl_write_urb;
struct urb *ctl_read_urb;
unsigned char *ctl_write_buffer;
unsigned char *ctl_read_buffer;
volatile int ctl_write_pend_flag;
volatile int ctl_read_pend_flag;
volatile int ctl_timeout_flag;
struct completion ctl_done;
unsigned char cmd_buffer[PVR2_CTL_BUFFSIZE];
int cmd_debug_state; // Low level command debugging info
unsigned char cmd_debug_code; //
unsigned int cmd_debug_write_len; //
unsigned int cmd_debug_read_len; //
int flag_ok; // device in known good state
int flag_disconnected; // flag_ok == 0 due to disconnect
int flag_init_ok; // true if structure is fully initialized
int flag_streaming_enabled; // true if streaming should be on
int flag_decoder_is_tuned;
struct pvr2_decoder_ctrl *decoder_ctrl;
// CPU firmware info (used to help find / save firmware data)
char *fw_buffer;
unsigned int fw_size;
// Which subsystem pieces have been enabled / configured
unsigned long subsys_enabled_mask;
// Which subsystems are manipulated to enable streaming
unsigned long subsys_stream_mask;
/* Tuner / frequency control stuff */
unsigned int tuner_type;
int tuner_updated;
unsigned long video_standards;
int unit_number; /* ID for driver instance */
unsigned long serial_number; /* ID for hardware itself */
/* Minor number used by v4l logic (yes, this is a hack, as there should
be no v4l junk here). Probably a better way to do this. */
int v4l_minor_number;
enum pvr2_config config;
/* Information about what audio signal we're hearing */
int flag_stereo;
int flag_bilingual;
struct pvr2_audio_stat *audio_stat;
/* Every last bit of controllable state */
struct pvr2_ctl_state controls[PVR2_CID_COUNT];
};
int pvr2_hdw_set_ctl_value_internal(struct pvr2_hdw *hdw,
unsigned int ctl_id,int value);
int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
#endif /* __PVRUSB2_HDW_INTERNAL_H */
/*
Stuff for Emacs to see, in order to encourage consistent editing style:
*** Local Variables: ***
*** mode: c ***
*** fill-column: 75 ***
*** tab-width: 8 ***
*** c-basic-offset: 8 ***
*** End: ***
*/
|