void palman_load_pixels() { // open pixels.tbl read_file_text("pixels.tbl"); reset_parse(); // parse pixels while(!optional_string("#END")){ // nondarkening pixel if(required_string("+ND")){ stuff_byte(&Palman_non_darkening_default[Palman_num_nondarkening_default][0]); stuff_byte(&Palman_non_darkening_default[Palman_num_nondarkening_default][1]); stuff_byte(&Palman_non_darkening_default[Palman_num_nondarkening_default++][2]); } } // set this to be the active table palman_set_nondarkening(Palman_non_darkening_default, Palman_num_nondarkening_default); }
/* * Function async_wrap (tty, *tx_buff, buffsize) */ int async_wrap_tty(struct tty_struct *tty, __u8 *tx_buff, int buffsize) { struct shirda_ldisc_admin_t *sp = tty->disc_data; int xbofs; int i; int n; union { __u16 value; __u8 bytes[2]; } fcs; /* Initialize variables */ fcs.value = INIT_FCS; n = 0; /* * Send XBOF's for required min. turn time and for the negotiated * additional XBOFS */ xbofs = sp->qos.add_bof; SHIRDA_DEBUGLOG("abofs=%d\n", xbofs); /* Check that we never use more than 115 + 48 xbofs */ if (xbofs > 163) { IRDALOG_WARNING("too many xbofs (%d)\n", xbofs); xbofs = 163; } memset(tx_buff + n, XBOF, xbofs); n += xbofs; /* Start of packet character BOF */ tx_buff[n++] = BOF; SHIRDA_DEBUGLOG("tx_payload length=%d\n", sp->nr_tx_payload); /* Insert frame and calc CRC */ for (i=0; i < sp->nr_tx_payload; i++) { /* * Check for the possibility of tx buffer overflow. We use * bufsize-5 since the maximum number of bytes that can be * transmitted after this point is 5. */ if(n >= (buffsize-5)) { IRDALOG_ERROR("tx buffer overflow (n=%d)\n", n); return -1; } n += stuff_byte(sp->tx_payload[i], tx_buff+n); fcs.value = irda_fcs(fcs.value, sp->tx_payload[i]); SHIRDA_DEBUGLOG("len=%04d:%04d, data=0x%02x, fcs=0x%04x\n", i, n, sp->tx_payload[i], fcs.value); } /* Insert CRC in little endian format (LSB first) */ fcs.value = ~fcs.value; #ifdef __LITTLE_ENDIAN n += stuff_byte(fcs.bytes[0], tx_buff+n); n += stuff_byte(fcs.bytes[1], tx_buff+n); #else /* ifdef __BIG_ENDIAN */ n += stuff_byte(fcs.bytes[1], tx_buff+n); n += stuff_byte(fcs.bytes[0], tx_buff+n); #endif tx_buff[n++] = EOF; SHIRDA_DEBUGLOG("tx_buff length=%d\n", n); return n; }
/* * Function async_wrap (skb, *tx_buff, buffsize) * * Makes a new buffer with wrapping and stuffing, should check that * we don't get tx buffer overflow. */ int async_wrap_skb(struct sk_buff *skb, __u8 *tx_buff, int buffsize) { struct irda_skb_cb *cb = (struct irda_skb_cb *) skb->cb; int xbofs; int i; int n; union { __u16 value; __u8 bytes[2]; } fcs; /* Initialize variables */ fcs.value = INIT_FCS; n = 0; /* * Send XBOF's for required min. turn time and for the negotiated * additional XBOFS */ if (cb->magic != LAP_MAGIC) { /* * This will happen for all frames sent from user-space. * Nothing to worry about, but we set the default number of * BOF's */ IRDA_DEBUG(1, "%s(), wrong magic in skb!\n", __FUNCTION__); xbofs = 10; } else xbofs = cb->xbofs + cb->xbofs_delay; IRDA_DEBUG(4, "%s(), xbofs=%d\n", __FUNCTION__, xbofs); /* Check that we never use more than 115 + 48 xbofs */ if (xbofs > 163) { IRDA_DEBUG(0, "%s(), too many xbofs (%d)\n", __FUNCTION__, xbofs); xbofs = 163; } memset(tx_buff + n, XBOF, xbofs); n += xbofs; /* Start of packet character BOF */ tx_buff[n++] = BOF; /* Insert frame and calc CRC */ for (i=0; i < skb->len; i++) { /* * Check for the possibility of tx buffer overflow. We use * bufsize-5 since the maximum number of bytes that can be * transmitted after this point is 5. */ if(n >= (buffsize-5)) { IRDA_ERROR("%s(), tx buffer overflow (n=%d)\n", __FUNCTION__, n); return n; } n += stuff_byte(skb->data[i], tx_buff+n); fcs.value = irda_fcs(fcs.value, skb->data[i]); } /* Insert CRC in little endian format (LSB first) */ fcs.value = ~fcs.value; #ifdef __LITTLE_ENDIAN n += stuff_byte(fcs.bytes[0], tx_buff+n); n += stuff_byte(fcs.bytes[1], tx_buff+n); #else /* ifdef __BIG_ENDIAN */ n += stuff_byte(fcs.bytes[1], tx_buff+n); n += stuff_byte(fcs.bytes[0], tx_buff+n); #endif tx_buff[n++] = EOF; return n; }