Lines Matching refs:inbuf
49 static unsigned cmd_loop(unsigned numbytes, struct inbuf_t *inbuf) in cmd_loop() argument
51 unsigned char *src = inbuf->data + inbuf->head; in cmd_loop()
52 struct cardstate *cs = inbuf->cs; in cmd_loop()
86 if (cs->dle && !(inbuf->inputstate & INS_DLE_command)) in cmd_loop()
87 inbuf->inputstate &= ~INS_command; in cmd_loop()
93 if (inbuf->inputstate & INS_DLE_char) { in cmd_loop()
95 inbuf->inputstate &= ~INS_DLE_char; in cmd_loop()
97 (inbuf->inputstate & INS_DLE_command)) { in cmd_loop()
99 inbuf->inputstate |= INS_DLE_char; in cmd_loop()
121 static unsigned lock_loop(unsigned numbytes, struct inbuf_t *inbuf) in lock_loop() argument
123 unsigned char *src = inbuf->data + inbuf->head; in lock_loop()
126 gigaset_if_receive(inbuf->cs, src, numbytes); in lock_loop()
138 static unsigned hdlc_loop(unsigned numbytes, struct inbuf_t *inbuf) in hdlc_loop() argument
140 struct cardstate *cs = inbuf->cs; in hdlc_loop()
145 unsigned char *src = inbuf->data + inbuf->head; in hdlc_loop()
285 static unsigned iraw_loop(unsigned numbytes, struct inbuf_t *inbuf) in iraw_loop() argument
287 struct cardstate *cs = inbuf->cs; in iraw_loop()
291 unsigned char *src = inbuf->data + inbuf->head; in iraw_loop()
338 static void handle_dle(struct inbuf_t *inbuf) in handle_dle() argument
340 struct cardstate *cs = inbuf->cs; in handle_dle()
345 if (!(inbuf->inputstate & INS_DLE_char)) { in handle_dle()
347 if (inbuf->data[inbuf->head] == DLE_FLAG && in handle_dle()
348 (cs->dle || inbuf->inputstate & INS_DLE_command)) { in handle_dle()
350 inbuf->head++; in handle_dle()
351 if (inbuf->head == inbuf->tail || in handle_dle()
352 inbuf->head == RBUFSIZE) { in handle_dle()
354 inbuf->inputstate |= INS_DLE_char; in handle_dle()
364 inbuf->inputstate &= ~INS_DLE_char; in handle_dle()
366 switch (inbuf->data[inbuf->head]) { in handle_dle()
368 if (inbuf->inputstate & INS_command) in handle_dle()
371 inbuf->inputstate |= INS_command | INS_DLE_command; in handle_dle()
372 inbuf->head++; /* byte consumed */ in handle_dle()
375 if (!(inbuf->inputstate & INS_DLE_command)) in handle_dle()
378 inbuf->inputstate &= ~INS_DLE_command; in handle_dle()
381 inbuf->inputstate &= ~INS_command; in handle_dle()
382 inbuf->head++; /* byte consumed */ in handle_dle()
386 inbuf->inputstate |= INS_DLE_char; in handle_dle()
387 if (!(cs->dle || inbuf->inputstate & INS_DLE_command)) in handle_dle()
393 inbuf->data[inbuf->head]); in handle_dle()
407 void gigaset_m10x_input(struct inbuf_t *inbuf) in gigaset_m10x_input() argument
409 struct cardstate *cs = inbuf->cs; in gigaset_m10x_input()
412 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", inbuf->head, inbuf->tail); in gigaset_m10x_input()
414 while (inbuf->head != inbuf->tail) { in gigaset_m10x_input()
416 handle_dle(inbuf); in gigaset_m10x_input()
419 numbytes = (inbuf->head > inbuf->tail ? in gigaset_m10x_input()
420 RBUFSIZE : inbuf->tail) - inbuf->head; in gigaset_m10x_input()
428 procbytes = lock_loop(numbytes, inbuf); in gigaset_m10x_input()
429 else if (inbuf->inputstate & INS_command) in gigaset_m10x_input()
430 procbytes = cmd_loop(numbytes, inbuf); in gigaset_m10x_input()
432 procbytes = hdlc_loop(numbytes, inbuf); in gigaset_m10x_input()
434 procbytes = iraw_loop(numbytes, inbuf); in gigaset_m10x_input()
435 inbuf->head += procbytes; in gigaset_m10x_input()
438 if (inbuf->head >= RBUFSIZE) in gigaset_m10x_input()
439 inbuf->head = 0; in gigaset_m10x_input()
441 gig_dbg(DEBUG_INTR, "head set to %u", inbuf->head); in gigaset_m10x_input()