diff options
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-hdw.h')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.h | 135 |
1 files changed, 70 insertions, 65 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h index e2f9d5e4cb65..383685f7c81f 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h | |||
@@ -44,27 +44,6 @@ | |||
44 | #define PVR2_CVAL_INPUT_COMPOSITE 2 | 44 | #define PVR2_CVAL_INPUT_COMPOSITE 2 |
45 | #define PVR2_CVAL_INPUT_RADIO 3 | 45 | #define PVR2_CVAL_INPUT_RADIO 3 |
46 | 46 | ||
47 | /* Subsystem definitions - these are various pieces that can be | ||
48 | independently stopped / started. Usually you don't want to mess with | ||
49 | this directly (let the driver handle things itself), but it is useful | ||
50 | for debugging. */ | ||
51 | #define PVR2_SUBSYS_B_ENC_FIRMWARE 0 | ||
52 | #define PVR2_SUBSYS_B_ENC_CFG 1 | ||
53 | #define PVR2_SUBSYS_B_DIGITIZER_RUN 2 | ||
54 | #define PVR2_SUBSYS_B_USBSTREAM_RUN 3 | ||
55 | #define PVR2_SUBSYS_B_ENC_RUN 4 | ||
56 | |||
57 | #define PVR2_SUBSYS_CFG_ALL ( \ | ||
58 | (1 << PVR2_SUBSYS_B_ENC_FIRMWARE) | \ | ||
59 | (1 << PVR2_SUBSYS_B_ENC_CFG) ) | ||
60 | #define PVR2_SUBSYS_RUN_ALL ( \ | ||
61 | (1 << PVR2_SUBSYS_B_DIGITIZER_RUN) | \ | ||
62 | (1 << PVR2_SUBSYS_B_USBSTREAM_RUN) | \ | ||
63 | (1 << PVR2_SUBSYS_B_ENC_RUN) ) | ||
64 | #define PVR2_SUBSYS_ALL ( \ | ||
65 | PVR2_SUBSYS_CFG_ALL | \ | ||
66 | PVR2_SUBSYS_RUN_ALL ) | ||
67 | |||
68 | enum pvr2_config { | 47 | enum pvr2_config { |
69 | pvr2_config_empty, /* No configuration */ | 48 | pvr2_config_empty, /* No configuration */ |
70 | pvr2_config_mpeg, /* Encoded / compressed video */ | 49 | pvr2_config_mpeg, /* Encoded / compressed video */ |
@@ -79,8 +58,41 @@ enum pvr2_v4l_type { | |||
79 | pvr2_v4l_type_radio, | 58 | pvr2_v4l_type_radio, |
80 | }; | 59 | }; |
81 | 60 | ||
61 | /* Major states that we can be in: | ||
62 | * | ||
63 | * DEAD - Device is in an unusable state and cannot be recovered. This | ||
64 | * can happen if we completely lose the ability to communicate with it | ||
65 | * (but it might still on the bus). In this state there's nothing we can | ||
66 | * do; it must be replugged in order to recover. | ||
67 | * | ||
68 | * COLD - Device is in an unusuable state, needs microcontroller firmware. | ||
69 | * | ||
70 | * WARM - We can communicate with the device and the proper | ||
71 | * microcontroller firmware is running, but other device initialization is | ||
72 | * still needed (e.g. encoder firmware). | ||
73 | * | ||
74 | * ERROR - A problem prevents capture operation (e.g. encoder firmware | ||
75 | * missing). | ||
76 | * | ||
77 | * READY - Device is operational, but not streaming. | ||
78 | * | ||
79 | * RUN - Device is streaming. | ||
80 | * | ||
81 | */ | ||
82 | #define PVR2_STATE_NONE 0 | ||
83 | #define PVR2_STATE_DEAD 1 | ||
84 | #define PVR2_STATE_COLD 2 | ||
85 | #define PVR2_STATE_WARM 3 | ||
86 | #define PVR2_STATE_ERROR 4 | ||
87 | #define PVR2_STATE_READY 5 | ||
88 | #define PVR2_STATE_RUN 6 | ||
89 | |||
90 | /* Translate configuration enum to a string label */ | ||
82 | const char *pvr2_config_get_name(enum pvr2_config); | 91 | const char *pvr2_config_get_name(enum pvr2_config); |
83 | 92 | ||
93 | /* Translate a master state enum to a string label */ | ||
94 | const char *pvr2_hdw_get_state_name(unsigned int); | ||
95 | |||
84 | struct pvr2_hdw; | 96 | struct pvr2_hdw; |
85 | 97 | ||
86 | /* Create and return a structure for interacting with the underlying | 98 | /* Create and return a structure for interacting with the underlying |
@@ -88,28 +100,13 @@ struct pvr2_hdw; | |||
88 | struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | 100 | struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, |
89 | const struct usb_device_id *devid); | 101 | const struct usb_device_id *devid); |
90 | 102 | ||
91 | /* Poll for background activity (if any) */ | ||
92 | void pvr2_hdw_poll(struct pvr2_hdw *); | ||
93 | |||
94 | /* Trigger a poll to take place later at a convenient time */ | ||
95 | void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *); | ||
96 | |||
97 | /* Register a callback used to trigger a future poll */ | ||
98 | void pvr2_hdw_setup_poll_trigger(struct pvr2_hdw *, | ||
99 | void (*func)(void *), | ||
100 | void *data); | ||
101 | |||
102 | /* Destroy hardware interaction structure */ | 103 | /* Destroy hardware interaction structure */ |
103 | void pvr2_hdw_destroy(struct pvr2_hdw *); | 104 | void pvr2_hdw_destroy(struct pvr2_hdw *); |
104 | 105 | ||
105 | /* Set up the structure and attempt to put the device into a usable state. | 106 | /* Register a function to be called whenever the master state changes. */ |
106 | This can be a time-consuming operation, which is why it is not done | 107 | void pvr2_hdw_set_state_callback(struct pvr2_hdw *, |
107 | internally as part of the create() step. Return value is exactly the | 108 | void (*callback_func)(void *), |
108 | same as pvr2_hdw_init_ok(). */ | 109 | void *callback_data); |
109 | int pvr2_hdw_setup(struct pvr2_hdw *); | ||
110 | |||
111 | /* Initialization succeeded */ | ||
112 | int pvr2_hdw_init_ok(struct pvr2_hdw *); | ||
113 | 110 | ||
114 | /* Return true if in the ready (normal) state */ | 111 | /* Return true if in the ready (normal) state */ |
115 | int pvr2_hdw_dev_ok(struct pvr2_hdw *); | 112 | int pvr2_hdw_dev_ok(struct pvr2_hdw *); |
@@ -167,6 +164,9 @@ int pvr2_hdw_set_streaming(struct pvr2_hdw *,int); | |||
167 | /* Find out if streaming is on */ | 164 | /* Find out if streaming is on */ |
168 | int pvr2_hdw_get_streaming(struct pvr2_hdw *); | 165 | int pvr2_hdw_get_streaming(struct pvr2_hdw *); |
169 | 166 | ||
167 | /* Retrieve driver overall state */ | ||
168 | int pvr2_hdw_get_state(struct pvr2_hdw *); | ||
169 | |||
170 | /* Configure the type of stream to generate */ | 170 | /* Configure the type of stream to generate */ |
171 | int pvr2_hdw_set_stream_type(struct pvr2_hdw *, enum pvr2_config); | 171 | int pvr2_hdw_set_stream_type(struct pvr2_hdw *, enum pvr2_config); |
172 | 172 | ||
@@ -177,26 +177,6 @@ struct pvr2_stream *pvr2_hdw_get_video_stream(struct pvr2_hdw *); | |||
177 | int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std, | 177 | int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std, |
178 | unsigned int idx); | 178 | unsigned int idx); |
179 | 179 | ||
180 | /* Enable / disable various pieces of hardware. Items to change are | ||
181 | identified by bit positions within msk, and new state for each item is | ||
182 | identified by corresponding bit positions within val. */ | ||
183 | void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw, | ||
184 | unsigned long msk,unsigned long val); | ||
185 | |||
186 | /* Retrieve mask indicating which pieces of hardware are currently enabled | ||
187 | / configured. */ | ||
188 | unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *); | ||
189 | |||
190 | /* Adjust mask of what get shut down when streaming is stopped. This is a | ||
191 | debugging aid. */ | ||
192 | void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw, | ||
193 | unsigned long msk,unsigned long val); | ||
194 | |||
195 | /* Retrieve mask indicating which pieces of hardware are disabled when | ||
196 | streaming is turned off. */ | ||
197 | unsigned long pvr2_hdw_subsys_stream_get(struct pvr2_hdw *); | ||
198 | |||
199 | |||
200 | /* Enable / disable retrieval of CPU firmware or prom contents. This must | 180 | /* Enable / disable retrieval of CPU firmware or prom contents. This must |
201 | be enabled before pvr2_hdw_cpufw_get() will function. Note that doing | 181 | be enabled before pvr2_hdw_cpufw_get() will function. Note that doing |
202 | this may prevent the device from running (and leaving this mode may | 182 | this may prevent the device from running (and leaving this mode may |
@@ -253,6 +233,9 @@ void pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int); | |||
253 | /* Execute a USB-commanded device reset */ | 233 | /* Execute a USB-commanded device reset */ |
254 | void pvr2_hdw_device_reset(struct pvr2_hdw *); | 234 | void pvr2_hdw_device_reset(struct pvr2_hdw *); |
255 | 235 | ||
236 | /* Reset worker's error trapping circuit breaker */ | ||
237 | int pvr2_hdw_untrip(struct pvr2_hdw *); | ||
238 | |||
256 | /* Execute hard reset command (after this point it's likely that the | 239 | /* Execute hard reset command (after this point it's likely that the |
257 | encoder will have to be reconfigured). This also clears the "useless" | 240 | encoder will have to be reconfigured). This also clears the "useless" |
258 | state. */ | 241 | state. */ |
@@ -275,11 +258,21 @@ int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val); | |||
275 | struct pvr2_hdw_debug_info { | 258 | struct pvr2_hdw_debug_info { |
276 | int big_lock_held; | 259 | int big_lock_held; |
277 | int ctl_lock_held; | 260 | int ctl_lock_held; |
278 | int flag_ok; | ||
279 | int flag_disconnected; | 261 | int flag_disconnected; |
280 | int flag_init_ok; | 262 | int flag_init_ok; |
281 | int flag_streaming_enabled; | 263 | int flag_ok; |
282 | unsigned long subsys_flags; | 264 | int fw1_state; |
265 | int flag_decoder_missed; | ||
266 | int flag_tripped; | ||
267 | int state_encoder_ok; | ||
268 | int state_encoder_run; | ||
269 | int state_decoder_run; | ||
270 | int state_usbstream_run; | ||
271 | int state_decoder_quiescent; | ||
272 | int state_pipeline_config; | ||
273 | int state_pipeline_req; | ||
274 | int state_pipeline_pause; | ||
275 | int state_pipeline_idle; | ||
283 | int cmd_debug_state; | 276 | int cmd_debug_state; |
284 | int cmd_debug_write_len; | 277 | int cmd_debug_write_len; |
285 | int cmd_debug_read_len; | 278 | int cmd_debug_read_len; |
@@ -295,8 +288,20 @@ struct pvr2_hdw_debug_info { | |||
295 | diagnosing lockups. Note that this operation is completed without any | 288 | diagnosing lockups. Note that this operation is completed without any |
296 | kind of locking and so it is not atomic and may yield inconsistent | 289 | kind of locking and so it is not atomic and may yield inconsistent |
297 | results. This is *purely* a debugging aid. */ | 290 | results. This is *purely* a debugging aid. */ |
298 | void pvr2_hdw_get_debug_info(const struct pvr2_hdw *hdw, | 291 | void pvr2_hdw_get_debug_info_unlocked(const struct pvr2_hdw *hdw, |
299 | struct pvr2_hdw_debug_info *); | 292 | struct pvr2_hdw_debug_info *); |
293 | |||
294 | /* Intrusively retrieve internal state info - this is useful for | ||
295 | diagnosing overall driver state. This operation synchronizes against | ||
296 | the overall driver mutex - so if there are locking problems this will | ||
297 | likely hang! This is *purely* a debugging aid. */ | ||
298 | void pvr2_hdw_get_debug_info_locked(struct pvr2_hdw *hdw, | ||
299 | struct pvr2_hdw_debug_info *); | ||
300 | |||
301 | /* Report out several lines of text that describes driver internal state. | ||
302 | Results are written into the passed-in buffer. */ | ||
303 | unsigned int pvr2_hdw_state_report(struct pvr2_hdw *hdw, | ||
304 | char *buf_ptr,unsigned int buf_size); | ||
300 | 305 | ||
301 | /* Cause modules to log their state once */ | 306 | /* Cause modules to log their state once */ |
302 | void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw); | 307 | void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw); |