23 #include <linux/errno.h>
24 #include <linux/string.h>
26 #include <linux/slab.h>
28 #include <asm/uaccess.h>
30 #define BUFFER_COUNT 32
31 #define BUFFER_SIZE PAGE_ALIGN(0x4000)
65 if (idx < BUFFER_COUNT) {
76 static void pvr2_ioread_done(
struct pvr2_ioread *cp)
93 if (pvr2_ioread_init(cp) < 0) {
103 pvr2_ioread_done(cp);
118 if (!sync_key_ptr) sync_key_len = 0;
140 static void pvr2_ioread_stop(
struct pvr2_ioread *cp)
144 "/*---TRACE_READ---*/ pvr2_ioread_stop id=%p",cp);
155 "/*---TRACE_READ---*/ sync_state <== 0");
160 static int pvr2_ioread_start(
struct pvr2_ioread *cp)
165 if (!(cp->
stream))
return 0;
167 "/*---TRACE_READ---*/ pvr2_ioread_start id=%p",cp);
172 "/*---TRACE_READ---*/"
173 " pvr2_ioread_start id=%p"
176 pvr2_ioread_stop(cp);
188 "/*---TRACE_READ---*/ sync_state <== 1");
211 "/*---TRACE_READ---*/"
212 " pvr2_ioread_setup (tear-down) id=%p",cp);
213 pvr2_ioread_stop(cp);
222 "/*---TRACE_READ---*/"
223 " pvr2_ioread_setup (setup) id=%p",cp);
250 ret = pvr2_ioread_start(cp);
252 pvr2_ioread_stop(cp);
258 static int pvr2_ioread_get_buffer(
struct pvr2_ioread *cp)
269 "/*---TRACE_READ---*/"
270 " pvr2_ioread_read id=%p"
273 pvr2_ioread_stop(cp);
283 if (!cp->
c_buf)
break;
291 "/*---TRACE_READ---*/"
292 " pvr2_ioread_read id=%p"
295 pvr2_ioread_stop(cp);
309 static void pvr2_ioread_filter(
struct pvr2_ioread *cp)
320 if (!pvr2_ioread_get_buffer(cp))
break;
325 for (idx = cp->
c_data_offs; idx < cp->c_data_len; idx++) {
345 "/*---TRACE_READ---*/"
346 " sync_state <== 2 (skipped %u bytes)",
356 "ERROR: pvr2_ioread filter sync problem"
377 pvr2_ioread_filter(cp);
397 "/*---TRACE_READ---*/ data is %s",
406 unsigned int copied_cnt;
411 unsigned int req_cnt =
cnt;
415 "/*---TRACE_READ---*/ pvr2_ioread_read id=%p"
416 " ZERO Request? Returning zero.",cp);
421 if (stat < 0)
return stat;
431 if (!pvr2_ioread_get_buffer(cp)) {
452 if (bcnt > cnt) bcnt =
cnt;
473 "/*---TRACE_READ---*/"
474 " sync_state <== 0");
497 "/*---TRACE_READ---*/ pvr2_ioread_read"
498 " id=%p request=%d result=%d",