• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/media/video/pvrusb2/

Lines Matching refs:cp

53 static int pvr2_ioread_init(struct pvr2_ioread *cp)
57 cp->stream = NULL;
58 mutex_init(&cp->mutex);
61 cp->buffer_storage[idx] = kmalloc(BUFFER_SIZE,GFP_KERNEL);
62 if (!(cp->buffer_storage[idx])) break;
68 if (!(cp->buffer_storage[idx])) continue;
69 kfree(cp->buffer_storage[idx]);
76 static void pvr2_ioread_done(struct pvr2_ioread *cp)
80 pvr2_ioread_setup(cp,NULL);
82 if (!(cp->buffer_storage[idx])) continue;
83 kfree(cp->buffer_storage[idx]);
89 struct pvr2_ioread *cp;
90 cp = kzalloc(sizeof(*cp),GFP_KERNEL);
91 if (!cp) return NULL;
92 pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_create id=%p",cp);
93 if (pvr2_ioread_init(cp) < 0) {
94 kfree(cp);
97 return cp;
100 void pvr2_ioread_destroy(struct pvr2_ioread *cp)
102 if (!cp) return;
103 pvr2_ioread_done(cp);
104 pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_destroy id=%p",cp);
105 if (cp->sync_key_ptr) {
106 kfree(cp->sync_key_ptr);
107 cp->sync_key_ptr = NULL;
109 kfree(cp);
112 void pvr2_ioread_set_sync_key(struct pvr2_ioread *cp,
116 if (!cp) return;
119 if ((sync_key_len == cp->sync_key_len) &&
121 (!memcmp(sync_key_ptr,cp->sync_key_ptr,sync_key_len)))) return;
123 if (sync_key_len != cp->sync_key_len) {
124 if (cp->sync_key_ptr) {
125 kfree(cp->sync_key_ptr);
126 cp->sync_key_ptr = NULL;
128 cp->sync_key_len = 0;
130 cp->sync_key_ptr = kmalloc(sync_key_len,GFP_KERNEL);
131 if (cp->sync_key_ptr) {
132 cp->sync_key_len = sync_key_len;
136 if (!cp->sync_key_len) return;
137 memcpy(cp->sync_key_ptr,sync_key_ptr,cp->sync_key_len);
140 static void pvr2_ioread_stop(struct pvr2_ioread *cp)
142 if (!(cp->enabled)) return;
144 "/*---TRACE_READ---*/ pvr2_ioread_stop id=%p",cp);
145 pvr2_stream_kill(cp->stream);
146 cp->c_buf = NULL;
147 cp->c_data_ptr = NULL;
148 cp->c_data_len = 0;
149 cp->c_data_offs = 0;
150 cp->enabled = 0;
151 cp->stream_running = 0;
152 cp->spigot_open = 0;
153 if (cp->sync_state) {
156 cp->sync_state = 0;
160 static int pvr2_ioread_start(struct pvr2_ioread *cp)
164 if (cp->enabled) return 0;
165 if (!(cp->stream)) return 0;
167 "/*---TRACE_READ---*/ pvr2_ioread_start id=%p",cp);
168 while ((bp = pvr2_stream_get_idle_buffer(cp->stream)) != NULL) {
175 cp,stat);
176 pvr2_ioread_stop(cp);
180 cp->enabled = !0;
181 cp->c_buf = NULL;
182 cp->c_data_ptr = NULL;
183 cp->c_data_len = 0;
184 cp->c_data_offs = 0;
185 cp->stream_running = 0;
186 if (cp->sync_key_len) {
189 cp->sync_state = 1;
190 cp->sync_trashed_count = 0;
191 cp->sync_buf_offs = 0;
193 cp->spigot_open = 0;
197 struct pvr2_stream *pvr2_ioread_get_stream(struct pvr2_ioread *cp)
199 return cp->stream;
202 int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp)
208 mutex_lock(&cp->mutex); do {
209 if (cp->stream) {
212 " pvr2_ioread_setup (tear-down) id=%p",cp);
213 pvr2_ioread_stop(cp);
214 pvr2_stream_kill(cp->stream);
215 if (pvr2_stream_get_buffer_count(cp->stream)) {
216 pvr2_stream_set_buffer_count(cp->stream,0);
218 cp->stream = NULL;
223 " pvr2_ioread_setup (setup) id=%p",cp);
227 mutex_unlock(&cp->mutex);
233 cp->buffer_storage[idx],
236 cp->stream = sp;
238 } while (0); mutex_unlock(&cp->mutex);
243 int pvr2_ioread_set_enabled(struct pvr2_ioread *cp,int fl)
246 if ((!fl) == (!(cp->enabled))) return ret;
248 mutex_lock(&cp->mutex); do {
250 ret = pvr2_ioread_start(cp);
252 pvr2_ioread_stop(cp);
254 } while (0); mutex_unlock(&cp->mutex);
258 static int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
262 while (cp->c_data_len <= cp->c_data_offs) {
263 if (cp->c_buf) {
265 stat = pvr2_buffer_queue(cp->c_buf);
272 cp,stat);
273 pvr2_ioread_stop(cp);
276 cp->c_buf = NULL;
277 cp->c_data_ptr = NULL;
278 cp->c_data_len = 0;
279 cp->c_data_offs = 0;
282 cp->c_buf = pvr2_stream_get_ready_buffer(cp->stream);
283 if (!cp->c_buf) break; // Nothing ready; done.
284 cp->c_data_len = pvr2_buffer_get_count(cp->c_buf);
285 if (!cp->c_data_len) {
287 stat = pvr2_buffer_get_status(cp->c_buf);
294 cp,stat);
295 pvr2_ioread_stop(cp);
302 cp->c_data_offs = 0;
303 cp->c_data_ptr = cp->buffer_storage[
304 pvr2_buffer_get_id(cp->c_buf)];
309 static void pvr2_ioread_filter(struct pvr2_ioread *cp)
312 if (!cp->enabled) return;
313 if (cp->sync_state != 1) return;
318 mutex_lock(&cp->mutex); while (1) {
320 if (!pvr2_ioread_get_buffer(cp)) break;
321 if (!cp->c_data_len) break;
325 for (idx = cp->c_data_offs; idx < cp->c_data_len; idx++) {
326 if (cp->sync_buf_offs >= cp->sync_key_len) break;
327 if (cp->c_data_ptr[idx] ==
328 cp->sync_key_ptr[cp->sync_buf_offs]) {
330 (cp->sync_buf_offs)++;
333 cp->sync_buf_offs = 0;
338 cp->c_data_offs += idx;
339 cp->sync_trashed_count += idx;
342 if (cp->sync_buf_offs >= cp->sync_key_len) {
343 cp->sync_trashed_count -= cp->sync_key_len;
347 cp->sync_trashed_count);
348 cp->sync_state = 2;
349 cp->sync_buf_offs = 0;
353 if (cp->c_data_offs < cp->c_data_len) {
358 cp->c_data_len,cp->c_data_offs);
365 } mutex_unlock(&cp->mutex);
368 int pvr2_ioread_avail(struct pvr2_ioread *cp)
371 if (!(cp->enabled)) {
376 if (cp->sync_state == 1) {
377 pvr2_ioread_filter(cp);
378 if (cp->sync_state == 1) return -EAGAIN;
382 if (cp->stream_running) {
383 if (!pvr2_stream_get_ready_count(cp->stream)) {
388 if (pvr2_stream_get_ready_count(cp->stream) < BUFFER_COUNT/2) {
394 if ((!(cp->spigot_open)) != (!(ret == 0))) {
395 cp->spigot_open = (ret == 0);
398 cp->spigot_open ? "available" : "pending");
404 int pvr2_ioread_read(struct pvr2_ioread *cp,void __user *buf,unsigned int cnt)
416 " ZERO Request? Returning zero.",cp);
420 stat = pvr2_ioread_avail(cp);
423 cp->stream_running = !0;
425 mutex_lock(&cp->mutex); do {
431 if (!pvr2_ioread_get_buffer(cp)) {
438 if (cp->sync_state == 2) {
441 src = cp->sync_key_ptr + cp->sync_buf_offs;
442 bcnt = cp->sync_key_len - cp->sync_buf_offs;
445 src = cp->c_data_ptr + cp->c_data_offs;
446 bcnt = cp->c_data_len - cp->c_data_offs;
465 if (cp->sync_state == 2) {
468 cp->sync_buf_offs += bcnt;
469 if (cp->sync_buf_offs >= cp->sync_key_len) {
475 cp->sync_state = 0;
479 cp->c_data_offs += bcnt;
483 } while (0); mutex_unlock(&cp->mutex);
499 cp,req_cnt,ret);