aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@stusta.de>2006-06-30 10:30:20 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-06-30 14:59:48 -0400
commit07e337eeab3660559cbe1fee6907d1092037aea7 (patch)
treed1960df404e80f7480c34a44f94ba599eb8df031 /drivers/media/video
parentc02a34f4e3e65a7b1fb64507ec5c093e8328335e (diff)
V4L/DVB (4287): Pvrusb2/: possible cleanups
This patch contains the following possible cleanups: - make needlessly global code static - #if 0 unused global functions Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-debugifc.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h17
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c114
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h32
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c22
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.h3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.c39
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.h13
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ioread.c8
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ioread.h1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c16
11 files changed, 74 insertions, 195 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
index 586900e365ff..8092b239cf27 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
@@ -337,8 +337,8 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
337} 337}
338 338
339 339
340int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf, 340static int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
341 unsigned int count) 341 unsigned int count)
342{ 342{
343 const char *wptr; 343 const char *wptr;
344 unsigned int wlen; 344 unsigned int wlen;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index ba2afbfe32c5..0d6dc33ca320 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -354,23 +354,6 @@ struct pvr2_hdw {
354 unsigned int control_cnt; 354 unsigned int control_cnt;
355}; 355};
356 356
357int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
358
359unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *);
360
361void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
362 unsigned long msk,unsigned long val);
363void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
364 unsigned long msk,
365 unsigned long val);
366
367void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
368void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);
369
370int pvr2_i2c_basic_op(struct pvr2_hdw *,u8 i2c_addr,
371 u8 *wdata,u16 wlen,
372 u8 *rdata,u16 rlen);
373
374#endif /* __PVRUSB2_HDW_INTERNAL_H */ 357#endif /* __PVRUSB2_HDW_INTERNAL_H */
375 358
376/* 359/*
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index c6105bce4fe8..9638591cc06f 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -88,7 +88,7 @@ static struct pvr2_string_table pvr2_client_lists[] = {
88}; 88};
89 89
90static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = 0}; 90static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = 0};
91DECLARE_MUTEX(pvr2_unit_sem); 91static DECLARE_MUTEX(pvr2_unit_sem);
92 92
93static int ctlchg = 0; 93static int ctlchg = 0;
94static int initusbreset = 1; 94static int initusbreset = 1;
@@ -261,6 +261,25 @@ static const char *control_values_subsystem[] = {
261 [PVR2_SUBSYS_B_ENC_RUN] = "enc_run", 261 [PVR2_SUBSYS_B_ENC_RUN] = "enc_run",
262}; 262};
263 263
264static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
265static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
266static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw);
267static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw);
268static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
269static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);
270static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw);
271static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
272 unsigned long msk,
273 unsigned long val);
274static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
275 unsigned long msk,
276 unsigned long val);
277static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
278 unsigned int timeout,int probe_fl,
279 void *write_data,unsigned int write_len,
280 void *read_data,unsigned int read_len);
281static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res);
282static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res);
264 283
265static int ctrl_channelfreq_get(struct pvr2_ctrl *cptr,int *vp) 284static int ctrl_channelfreq_get(struct pvr2_ctrl *cptr,int *vp)
266{ 285{
@@ -834,14 +853,6 @@ unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *hdw)
834} 853}
835 854
836 855
837struct pvr2_hdw *pvr2_hdw_find(int unit_number)
838{
839 if (unit_number < 0) return 0;
840 if (unit_number >= PVR_NUM) return 0;
841 return unit_pointers[unit_number];
842}
843
844
845int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw) 856int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw)
846{ 857{
847 return hdw->unit_number; 858 return hdw->unit_number;
@@ -915,7 +926,7 @@ static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
915 * is not suitable for an usb transaction. 926 * is not suitable for an usb transaction.
916 * 927 *
917 */ 928 */
918int pvr2_upload_firmware1(struct pvr2_hdw *hdw) 929static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
919{ 930{
920 const struct firmware *fw_entry = 0; 931 const struct firmware *fw_entry = 0;
921 void *fw_ptr; 932 void *fw_ptr;
@@ -1164,8 +1175,9 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1164 reconfigure and start over. 1175 reconfigure and start over.
1165 1176
1166*/ 1177*/
1167void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw, 1178static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
1168 unsigned long msk,unsigned long val) 1179 unsigned long msk,
1180 unsigned long val)
1169{ 1181{
1170 unsigned long nmsk; 1182 unsigned long nmsk;
1171 unsigned long vmsk; 1183 unsigned long vmsk;
@@ -1316,18 +1328,6 @@ void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
1316} 1328}
1317 1329
1318 1330
1319void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk)
1320{
1321 pvr2_hdw_subsys_bit_chg(hdw,msk,msk);
1322}
1323
1324
1325void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk)
1326{
1327 pvr2_hdw_subsys_bit_chg(hdw,msk,0);
1328}
1329
1330
1331unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *hdw) 1331unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *hdw)
1332{ 1332{
1333 return hdw->subsys_enabled_mask; 1333 return hdw->subsys_enabled_mask;
@@ -1340,9 +1340,9 @@ unsigned long pvr2_hdw_subsys_stream_get(struct pvr2_hdw *hdw)
1340} 1340}
1341 1341
1342 1342
1343void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw, 1343static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
1344 unsigned long msk, 1344 unsigned long msk,
1345 unsigned long val) 1345 unsigned long val)
1346{ 1346{
1347 unsigned long val2; 1347 unsigned long val2;
1348 msk &= PVR2_SUBSYS_ALL; 1348 msk &= PVR2_SUBSYS_ALL;
@@ -1364,7 +1364,7 @@ void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw,
1364} 1364}
1365 1365
1366 1366
1367int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl) 1367static int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl)
1368{ 1368{
1369 if ((!enableFl) == !(hdw->flag_streaming_enabled)) return 0; 1369 if ((!enableFl) == !(hdw->flag_streaming_enabled)) return 0;
1370 if (enableFl) { 1370 if (enableFl) {
@@ -1398,8 +1398,8 @@ int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag)
1398} 1398}
1399 1399
1400 1400
1401int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw, 1401static int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
1402 enum pvr2_config config) 1402 enum pvr2_config config)
1403{ 1403{
1404 unsigned long sm = hdw->subsys_enabled_mask; 1404 unsigned long sm = hdw->subsys_enabled_mask;
1405 if (!hdw->flag_ok) return -EIO; 1405 if (!hdw->flag_ok) return -EIO;
@@ -1926,7 +1926,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1926 1926
1927/* Remove _all_ associations between this driver and the underlying USB 1927/* Remove _all_ associations between this driver and the underlying USB
1928 layer. */ 1928 layer. */
1929void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw) 1929static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw)
1930{ 1930{
1931 if (hdw->flag_disconnected) return; 1931 if (hdw->flag_disconnected) return;
1932 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw); 1932 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw);
@@ -2016,7 +2016,7 @@ void pvr2_hdw_disconnect(struct pvr2_hdw *hdw)
2016 2016
2017// Attempt to autoselect an appropriate value for std_enum_cur given 2017// Attempt to autoselect an appropriate value for std_enum_cur given
2018// whatever is currently in std_mask_cur 2018// whatever is currently in std_mask_cur
2019void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw) 2019static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
2020{ 2020{
2021 unsigned int idx; 2021 unsigned int idx;
2022 for (idx = 1; idx < hdw->std_enum_cnt; idx++) { 2022 for (idx = 1; idx < hdw->std_enum_cnt; idx++) {
@@ -2031,7 +2031,7 @@ void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
2031 2031
2032// Calculate correct set of enumerated standards based on currently known 2032// Calculate correct set of enumerated standards based on currently known
2033// set of available standards bits. 2033// set of available standards bits.
2034void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw) 2034static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
2035{ 2035{
2036 struct v4l2_standard *newstd; 2036 struct v4l2_standard *newstd;
2037 unsigned int std_cnt; 2037 unsigned int std_cnt;
@@ -2180,7 +2180,7 @@ static const char *get_ctrl_typename(enum pvr2_ctl_type tp)
2180 state(s) back to their previous value before this function was called. 2180 state(s) back to their previous value before this function was called.
2181 Thus we can automatically reconfigure affected pieces of the driver as 2181 Thus we can automatically reconfigure affected pieces of the driver as
2182 controls are changed. */ 2182 controls are changed. */
2183int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw) 2183static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
2184{ 2184{
2185 unsigned long saved_subsys_mask = hdw->subsys_enabled_mask; 2185 unsigned long saved_subsys_mask = hdw->subsys_enabled_mask;
2186 unsigned long stale_subsys_mask = 0; 2186 unsigned long stale_subsys_mask = 0;
@@ -2319,14 +2319,6 @@ void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *hdw)
2319} 2319}
2320 2320
2321 2321
2322void pvr2_hdw_poll_trigger(struct pvr2_hdw *hdw)
2323{
2324 LOCK_TAKE(hdw->big_lock); do {
2325 pvr2_hdw_poll_trigger_unlocked(hdw);
2326 } while (0); LOCK_GIVE(hdw->big_lock);
2327}
2328
2329
2330/* Return name for this driver instance */ 2322/* Return name for this driver instance */
2331const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw) 2323const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
2332{ 2324{
@@ -2335,7 +2327,7 @@ const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
2335 2327
2336 2328
2337/* Return bit mask indicating signal status */ 2329/* Return bit mask indicating signal status */
2338unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw) 2330static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw)
2339{ 2331{
2340 unsigned int msk = 0; 2332 unsigned int msk = 0;
2341 switch (hdw->input_val) { 2333 switch (hdw->input_val) {
@@ -2517,22 +2509,6 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int v)
2517} 2509}
2518 2510
2519 2511
2520void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw)
2521{
2522 if (!hdw->usb_dev) return;
2523 usb_settoggle(hdw->usb_dev, PVR2_CTL_WRITE_ENDPOINT & 0xf,
2524 !(PVR2_CTL_WRITE_ENDPOINT & USB_DIR_IN), 0);
2525 usb_settoggle(hdw->usb_dev, PVR2_CTL_READ_ENDPOINT & 0xf,
2526 !(PVR2_CTL_READ_ENDPOINT & USB_DIR_IN), 0);
2527 usb_clear_halt(hdw->usb_dev,
2528 usb_rcvbulkpipe(hdw->usb_dev,
2529 PVR2_CTL_READ_ENDPOINT & 0x7f));
2530 usb_clear_halt(hdw->usb_dev,
2531 usb_sndbulkpipe(hdw->usb_dev,
2532 PVR2_CTL_WRITE_ENDPOINT & 0x7f));
2533}
2534
2535
2536static void pvr2_ctl_write_complete(struct urb *urb, struct pt_regs *regs) 2512static void pvr2_ctl_write_complete(struct urb *urb, struct pt_regs *regs)
2537{ 2513{
2538 struct pvr2_hdw *hdw = urb->context; 2514 struct pvr2_hdw *hdw = urb->context;
@@ -2566,10 +2542,10 @@ static void pvr2_ctl_timeout(unsigned long data)
2566} 2542}
2567 2543
2568 2544
2569int pvr2_send_request_ex(struct pvr2_hdw *hdw, 2545static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
2570 unsigned int timeout,int probe_fl, 2546 unsigned int timeout,int probe_fl,
2571 void *write_data,unsigned int write_len, 2547 void *write_data,unsigned int write_len,
2572 void *read_data,unsigned int read_len) 2548 void *read_data,unsigned int read_len)
2573{ 2549{
2574 unsigned int idx; 2550 unsigned int idx;
2575 int status = 0; 2551 int status = 0;
@@ -2824,7 +2800,7 @@ int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data)
2824} 2800}
2825 2801
2826 2802
2827int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data) 2803static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
2828{ 2804{
2829 int ret = 0; 2805 int ret = 0;
2830 2806
@@ -2848,7 +2824,7 @@ int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
2848} 2824}
2849 2825
2850 2826
2851int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res) 2827static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
2852{ 2828{
2853 int ret; 2829 int ret;
2854 2830
@@ -2865,7 +2841,7 @@ int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
2865} 2841}
2866 2842
2867 2843
2868int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res) 2844static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
2869{ 2845{
2870 int ret; 2846 int ret;
2871 2847
@@ -2881,7 +2857,7 @@ int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
2881} 2857}
2882 2858
2883 2859
2884void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw) 2860static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw)
2885{ 2861{
2886 if (!hdw->flag_ok) return; 2862 if (!hdw->flag_ok) return;
2887 pvr2_trace(PVR2_TRACE_INIT,"render_useless"); 2863 pvr2_trace(PVR2_TRACE_INIT,"render_useless");
@@ -2994,7 +2970,7 @@ int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw)
2994} 2970}
2995 2971
2996 2972
2997int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl) 2973static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
2998{ 2974{
2999 int status; 2975 int status;
3000 LOCK_TAKE(hdw->ctl_lock); do { 2976 LOCK_TAKE(hdw->ctl_lock); do {
@@ -3092,7 +3068,7 @@ int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val)
3092} 3068}
3093 3069
3094 3070
3095int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) 3071static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
3096{ 3072{
3097 int result; 3073 int result;
3098 LOCK_TAKE(hdw->ctl_lock); do { 3074 LOCK_TAKE(hdw->ctl_lock); do {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index 63f529154431..fd931b5da490 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -91,7 +91,6 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
91void pvr2_hdw_poll(struct pvr2_hdw *); 91void pvr2_hdw_poll(struct pvr2_hdw *);
92 92
93/* Trigger a poll to take place later at a convenient time */ 93/* Trigger a poll to take place later at a convenient time */
94void pvr2_hdw_poll_trigger(struct pvr2_hdw *);
95void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *); 94void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *);
96 95
97/* Register a callback used to trigger a future poll */ 96/* Register a callback used to trigger a future poll */
@@ -99,9 +98,6 @@ void pvr2_hdw_setup_poll_trigger(struct pvr2_hdw *,
99 void (*func)(void *), 98 void (*func)(void *),
100 void *data); 99 void *data);
101 100
102/* Get pointer to structure given unit number */
103struct pvr2_hdw *pvr2_hdw_find(int unit_number);
104
105/* Destroy hardware interaction structure */ 101/* Destroy hardware interaction structure */
106void pvr2_hdw_destroy(struct pvr2_hdw *); 102void pvr2_hdw_destroy(struct pvr2_hdw *);
107 103
@@ -180,12 +176,6 @@ int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std,
180void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw, 176void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
181 unsigned long msk,unsigned long val); 177 unsigned long msk,unsigned long val);
182 178
183/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,msk) */
184void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk);
185
186/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,0) */
187void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk);
188
189/* Retrieve mask indicating which pieces of hardware are currently enabled 179/* Retrieve mask indicating which pieces of hardware are currently enabled
190 / configured. */ 180 / configured. */
191unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *); 181unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *);
@@ -225,34 +215,18 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);
225/* The following entry points are all lower level things you normally don't 215/* The following entry points are all lower level things you normally don't
226 want to worry about. */ 216 want to worry about. */
227 217
228/* Attempt to recover from a USB foul-up (in practice I find that if you
229 have to do this, then it's already too late). */
230void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw);
231
232/* Issue a command and get a response from the device. LOTS of higher 218/* Issue a command and get a response from the device. LOTS of higher
233 level stuff is built on this. */ 219 level stuff is built on this. */
234int pvr2_send_request(struct pvr2_hdw *, 220int pvr2_send_request(struct pvr2_hdw *,
235 void *write_ptr,unsigned int write_len, 221 void *write_ptr,unsigned int write_len,
236 void *read_ptr,unsigned int read_len); 222 void *read_ptr,unsigned int read_len);
237 223
238/* Issue a command and get a response from the device. This extended
239 version includes a probe flag (which if set means that device errors
240 should not be logged or treated as fatal) and a timeout in jiffies.
241 This can be used to non-lethally probe the health of endpoint 1. */
242int pvr2_send_request_ex(struct pvr2_hdw *,unsigned int timeout,int probe_fl,
243 void *write_ptr,unsigned int write_len,
244 void *read_ptr,unsigned int read_len);
245
246/* Slightly higher level device communication functions. */ 224/* Slightly higher level device communication functions. */
247int pvr2_write_register(struct pvr2_hdw *, u16, u32); 225int pvr2_write_register(struct pvr2_hdw *, u16, u32);
248int pvr2_read_register(struct pvr2_hdw *, u16, u32 *);
249int pvr2_write_u16(struct pvr2_hdw *, u16, int);
250int pvr2_write_u8(struct pvr2_hdw *, u8, int);
251 226
252/* Call if for any reason we can't talk to the hardware anymore - this will 227/* Call if for any reason we can't talk to the hardware anymore - this will
253 cause the driver to stop flailing on the device. */ 228 cause the driver to stop flailing on the device. */
254void pvr2_hdw_render_useless(struct pvr2_hdw *); 229void pvr2_hdw_render_useless(struct pvr2_hdw *);
255void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *);
256 230
257/* Set / clear 8051's reset bit */ 231/* Set / clear 8051's reset bit */
258void pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int); 232void pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int);
@@ -271,12 +245,6 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *);
271/* Order decoder to reset */ 245/* Order decoder to reset */
272int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *); 246int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *);
273 247
274/* Stop / start video stream transport */
275int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
276
277/* Find I2C address of eeprom */
278int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *);
279
280/* Direct manipulation of GPIO bits */ 248/* Direct manipulation of GPIO bits */
281int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *); 249int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *);
282int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *); 250int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index c8d0bdee3ff1..eca48c90b553 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -37,6 +37,10 @@ static unsigned int i2c_scan = 0;
37module_param(i2c_scan, int, S_IRUGO|S_IWUSR); 37module_param(i2c_scan, int, S_IRUGO|S_IWUSR);
38MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 38MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
39 39
40static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
41 unsigned int detail,
42 char *buf,unsigned int maxlen);
43
40static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */ 44static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
41 u8 i2c_addr, /* I2C address we're talking to */ 45 u8 i2c_addr, /* I2C address we're talking to */
42 u8 *data, /* Data to write */ 46 u8 *data, /* Data to write */
@@ -165,12 +169,12 @@ static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
165 169
166/* This is the common low level entry point for doing I2C operations to the 170/* This is the common low level entry point for doing I2C operations to the
167 hardware. */ 171 hardware. */
168int pvr2_i2c_basic_op(struct pvr2_hdw *hdw, 172static int pvr2_i2c_basic_op(struct pvr2_hdw *hdw,
169 u8 i2c_addr, 173 u8 i2c_addr,
170 u8 *wdata, 174 u8 *wdata,
171 u16 wlen, 175 u16 wlen,
172 u8 *rdata, 176 u8 *rdata,
173 u16 rlen) 177 u16 rlen)
174{ 178{
175 if (!rdata) rlen = 0; 179 if (!rdata) rlen = 0;
176 if (!wdata) wlen = 0; 180 if (!wdata) wlen = 0;
@@ -705,9 +709,9 @@ int pvr2_i2c_core_check_stale(struct pvr2_hdw *hdw)
705 return (hdw->i2c_pend_types & PVR2_I2C_PEND_ALL) != 0; 709 return (hdw->i2c_pend_types & PVR2_I2C_PEND_ALL) != 0;
706} 710}
707 711
708unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp, 712static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
709 unsigned int detail, 713 unsigned int detail,
710 char *buf,unsigned int maxlen) 714 char *buf,unsigned int maxlen)
711{ 715{
712 unsigned int ccnt,bcnt; 716 unsigned int ccnt,bcnt;
713 int spcfl = 0; 717 int spcfl = 0;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
index e8af5b0ed3ce..6d7e25247576 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
@@ -75,9 +75,6 @@ unsigned int pvr2_i2c_report(struct pvr2_hdw *,char *buf,unsigned int maxlen);
75 PVR2_I2C_DETAIL_DEBUG |\ 75 PVR2_I2C_DETAIL_DEBUG |\
76 PVR2_I2C_DETAIL_HANDLER |\ 76 PVR2_I2C_DETAIL_HANDLER |\
77 PVR2_I2C_DETAIL_CTLMASK) 77 PVR2_I2C_DETAIL_CTLMASK)
78unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *,
79 unsigned int detail_mask,
80 char *buf,unsigned int maxlen);
81 78
82void pvr2_i2c_probe(struct pvr2_hdw *,struct pvr2_i2c_client *); 79void pvr2_i2c_probe(struct pvr2_hdw *,struct pvr2_i2c_client *);
83const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx); 80const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c
index a984c91f571c..c032777a977f 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -93,7 +93,7 @@ struct pvr2_buffer {
93 struct urb *purb; 93 struct urb *purb;
94}; 94};
95 95
96const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st) 96static const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
97{ 97{
98 switch (st) { 98 switch (st) {
99 case pvr2_buffer_state_none: return "none"; 99 case pvr2_buffer_state_none: return "none";
@@ -104,7 +104,8 @@ const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
104 return "unknown"; 104 return "unknown";
105} 105}
106 106
107void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg) 107#ifdef SANITY_CHECK_BUFFERS
108static void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg)
108{ 109{
109 pvr2_trace(PVR2_TRACE_INFO, 110 pvr2_trace(PVR2_TRACE_INFO,
110 "buffer%s%s %p state=%s id=%d status=%d" 111 "buffer%s%s %p state=%s id=%d status=%d"
@@ -119,6 +120,7 @@ void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg)
119 (bp ? bp->purb : 0), 120 (bp ? bp->purb : 0),
120 (bp ? bp->signature : 0)); 121 (bp ? bp->signature : 0));
121} 122}
123#endif /* SANITY_CHECK_BUFFERS */
122 124
123static void pvr2_buffer_remove(struct pvr2_buffer *bp) 125static void pvr2_buffer_remove(struct pvr2_buffer *bp)
124{ 126{
@@ -513,10 +515,6 @@ void pvr2_stream_set_callback(struct pvr2_stream *sp,
513} 515}
514 516
515/* Query / set the nominal buffer count */ 517/* Query / set the nominal buffer count */
516int pvr2_stream_get_buffer_count(struct pvr2_stream *sp)
517{
518 return sp->buffer_target_count;
519}
520 518
521int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt) 519int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
522{ 520{
@@ -555,17 +553,6 @@ int pvr2_stream_get_ready_count(struct pvr2_stream *sp)
555 return sp->r_count; 553 return sp->r_count;
556} 554}
557 555
558int pvr2_stream_get_idle_count(struct pvr2_stream *sp)
559{
560 return sp->i_count;
561}
562
563void pvr2_stream_flush(struct pvr2_stream *sp)
564{
565 mutex_lock(&sp->mutex); do {
566 pvr2_stream_internal_flush(sp);
567 } while(0); mutex_unlock(&sp->mutex);
568}
569 556
570void pvr2_stream_kill(struct pvr2_stream *sp) 557void pvr2_stream_kill(struct pvr2_stream *sp)
571{ 558{
@@ -620,20 +607,6 @@ int pvr2_buffer_queue(struct pvr2_buffer *bp)
620 return ret; 607 return ret;
621} 608}
622 609
623int pvr2_buffer_idle(struct pvr2_buffer *bp)
624{
625 struct pvr2_stream *sp;
626 if (!bp) return -EINVAL;
627 sp = bp->stream;
628 mutex_lock(&sp->mutex); do {
629 pvr2_buffer_wipe(bp);
630 pvr2_buffer_set_idle(bp);
631 if (sp->buffer_total_count != sp->buffer_target_count) {
632 pvr2_stream_achieve_buffer_count(sp);
633 }
634 } while(0); mutex_unlock(&sp->mutex);
635 return 0;
636}
637 610
638int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt) 611int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt)
639{ 612{
@@ -673,10 +646,6 @@ int pvr2_buffer_get_status(struct pvr2_buffer *bp)
673 return bp->status; 646 return bp->status;
674} 647}
675 648
676enum pvr2_buffer_state pvr2_buffer_get_state(struct pvr2_buffer *bp)
677{
678 return bp->state;
679}
680 649
681int pvr2_buffer_get_id(struct pvr2_buffer *bp) 650int pvr2_buffer_get_id(struct pvr2_buffer *bp)
682{ 651{
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.h b/drivers/media/video/pvrusb2/pvrusb2-io.h
index 65e11385b2b3..96285ad234a6 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.h
@@ -36,8 +36,6 @@ enum pvr2_buffer_state {
36struct pvr2_stream; 36struct pvr2_stream;
37struct pvr2_buffer; 37struct pvr2_buffer;
38 38
39const char *pvr2_buffer_state_decode(enum pvr2_buffer_state);
40
41/* Initialize / tear down stream structure */ 39/* Initialize / tear down stream structure */
42struct pvr2_stream *pvr2_stream_create(void); 40struct pvr2_stream *pvr2_stream_create(void);
43void pvr2_stream_destroy(struct pvr2_stream *); 41void pvr2_stream_destroy(struct pvr2_stream *);
@@ -49,7 +47,6 @@ void pvr2_stream_set_callback(struct pvr2_stream *,
49 void *data); 47 void *data);
50 48
51/* Query / set the nominal buffer count */ 49/* Query / set the nominal buffer count */
52int pvr2_stream_get_buffer_count(struct pvr2_stream *);
53int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int); 50int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
54 51
55/* Get a pointer to a buffer that is either idle, ready, or is specified 52/* Get a pointer to a buffer that is either idle, ready, or is specified
@@ -59,12 +56,8 @@ struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
59struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id); 56struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
60 57
61/* Find out how many buffers are idle or ready */ 58/* Find out how many buffers are idle or ready */
62int pvr2_stream_get_idle_count(struct pvr2_stream *);
63int pvr2_stream_get_ready_count(struct pvr2_stream *); 59int pvr2_stream_get_ready_count(struct pvr2_stream *);
64 60
65/* Kill all pending operations */
66void pvr2_stream_flush(struct pvr2_stream *);
67
68/* Kill all pending buffers and throw away any ready buffers as well */ 61/* Kill all pending buffers and throw away any ready buffers as well */
69void pvr2_stream_kill(struct pvr2_stream *); 62void pvr2_stream_kill(struct pvr2_stream *);
70 63
@@ -77,18 +70,12 @@ unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
77/* Retrieve completion code for given ready buffer */ 70/* Retrieve completion code for given ready buffer */
78int pvr2_buffer_get_status(struct pvr2_buffer *); 71int pvr2_buffer_get_status(struct pvr2_buffer *);
79 72
80/* Retrieve state of given buffer */
81enum pvr2_buffer_state pvr2_buffer_get_state(struct pvr2_buffer *);
82
83/* Retrieve ID of given buffer */ 73/* Retrieve ID of given buffer */
84int pvr2_buffer_get_id(struct pvr2_buffer *); 74int pvr2_buffer_get_id(struct pvr2_buffer *);
85 75
86/* Start reading into given buffer (kill it if needed) */ 76/* Start reading into given buffer (kill it if needed) */
87int pvr2_buffer_queue(struct pvr2_buffer *); 77int pvr2_buffer_queue(struct pvr2_buffer *);
88 78
89/* Move buffer back to idle pool (kill it if needed) */
90int pvr2_buffer_idle(struct pvr2_buffer *);
91
92#endif /* __PVRUSB2_IO_H */ 79#endif /* __PVRUSB2_IO_H */
93 80
94/* 81/*
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ioread.c b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
index 49da062e3271..4dce1a462f50 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ioread.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
@@ -251,12 +251,8 @@ int pvr2_ioread_set_enabled(struct pvr2_ioread *cp,int fl)
251 return ret; 251 return ret;
252} 252}
253 253
254int pvr2_ioread_get_enabled(struct pvr2_ioread *cp)
255{
256 return cp->enabled != 0;
257}
258 254
259int pvr2_ioread_get_buffer(struct pvr2_ioread *cp) 255static int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
260{ 256{
261 int stat; 257 int stat;
262 258
@@ -307,7 +303,7 @@ int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
307 return !0; 303 return !0;
308} 304}
309 305
310void pvr2_ioread_filter(struct pvr2_ioread *cp) 306static void pvr2_ioread_filter(struct pvr2_ioread *cp)
311{ 307{
312 unsigned int idx; 308 unsigned int idx;
313 if (!cp->enabled) return; 309 if (!cp->enabled) return;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ioread.h b/drivers/media/video/pvrusb2/pvrusb2-ioread.h
index 6b002597f5de..1d362f833588 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ioread.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-ioread.h
@@ -33,7 +33,6 @@ void pvr2_ioread_set_sync_key(struct pvr2_ioread *,
33 const char *sync_key_ptr, 33 const char *sync_key_ptr,
34 unsigned int sync_key_len); 34 unsigned int sync_key_len);
35int pvr2_ioread_set_enabled(struct pvr2_ioread *,int fl); 35int pvr2_ioread_set_enabled(struct pvr2_ioread *,int fl);
36int pvr2_ioread_get_enabled(struct pvr2_ioread *);
37int pvr2_ioread_read(struct pvr2_ioread *,void __user *buf,unsigned int cnt); 36int pvr2_ioread_read(struct pvr2_ioread *,void __user *buf,unsigned int cnt);
38int pvr2_ioread_avail(struct pvr2_ioread *); 37int pvr2_ioread_avail(struct pvr2_ioread *);
39 38
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 59f5ef5558c8..b12c2a7f1359 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -81,7 +81,7 @@ static int video_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
81module_param_array(video_nr, int, NULL, 0444); 81module_param_array(video_nr, int, NULL, 0444);
82MODULE_PARM_DESC(video_nr, "Offset for device's minor"); 82MODULE_PARM_DESC(video_nr, "Offset for device's minor");
83 83
84struct v4l2_capability pvr_capability ={ 84static struct v4l2_capability pvr_capability ={
85 .driver = "pvrusb2", 85 .driver = "pvrusb2",
86 .card = "Hauppauge WinTV pvr-usb2", 86 .card = "Hauppauge WinTV pvr-usb2",
87 .bus_info = "usb", 87 .bus_info = "usb",
@@ -111,7 +111,7 @@ static struct v4l2_tuner pvr_v4l2_tuners[]= {
111 } 111 }
112}; 112};
113 113
114struct v4l2_fmtdesc pvr_fmtdesc [] = { 114static struct v4l2_fmtdesc pvr_fmtdesc [] = {
115 { 115 {
116 .index = 0, 116 .index = 0,
117 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, 117 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
@@ -127,7 +127,7 @@ struct v4l2_fmtdesc pvr_fmtdesc [] = {
127#define PVR_FORMAT_PIX 0 127#define PVR_FORMAT_PIX 0
128#define PVR_FORMAT_VBI 1 128#define PVR_FORMAT_VBI 1
129 129
130struct v4l2_format pvr_format [] = { 130static struct v4l2_format pvr_format [] = {
131 [PVR_FORMAT_PIX] = { 131 [PVR_FORMAT_PIX] = {
132 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, 132 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
133 .fmt = { 133 .fmt = {
@@ -724,7 +724,7 @@ static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
724} 724}
725 725
726 726
727void pvr2_v4l2_internal_check(struct pvr2_channel *chp) 727static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
728{ 728{
729 struct pvr2_v4l2 *vp; 729 struct pvr2_v4l2 *vp;
730 vp = container_of(chp,struct pvr2_v4l2,channel); 730 vp = container_of(chp,struct pvr2_v4l2,channel);
@@ -734,8 +734,8 @@ void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
734} 734}
735 735
736 736
737int pvr2_v4l2_ioctl(struct inode *inode, struct file *file, 737static int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
738 unsigned int cmd, unsigned long arg) 738 unsigned int cmd, unsigned long arg)
739{ 739{
740 740
741/* Temporary hack : use ivtv api until a v4l2 one is available. */ 741/* Temporary hack : use ivtv api until a v4l2 one is available. */
@@ -746,7 +746,7 @@ int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
746} 746}
747 747
748 748
749int pvr2_v4l2_release(struct inode *inode, struct file *file) 749static int pvr2_v4l2_release(struct inode *inode, struct file *file)
750{ 750{
751 struct pvr2_v4l2_fh *fhp = file->private_data; 751 struct pvr2_v4l2_fh *fhp = file->private_data;
752 struct pvr2_v4l2 *vp = fhp->vhead; 752 struct pvr2_v4l2 *vp = fhp->vhead;
@@ -793,7 +793,7 @@ int pvr2_v4l2_release(struct inode *inode, struct file *file)
793} 793}
794 794
795 795
796int pvr2_v4l2_open(struct inode *inode, struct file *file) 796static int pvr2_v4l2_open(struct inode *inode, struct file *file)
797{ 797{
798 struct pvr2_v4l2_dev *dip = 0; /* Our own context pointer */ 798 struct pvr2_v4l2_dev *dip = 0; /* Our own context pointer */
799 struct pvr2_v4l2_fh *fhp; 799 struct pvr2_v4l2_fh *fhp;