static void set_freq(void) { /* float tempfreq = 0.0; */ int write_return; /* * Can't use floating point in 2.6 kernel! * May be some loss of precision */ timerval = (1000000 / freq) / 2; write_control[0] = FREQ_HEADER; write_control[1] = timerval; write_control[2] = 0; write_return = write_to_usb(write_control, MCU_CTRL_SIZE, 0); if (write_return == MCU_CTRL_SIZE) printk(LIRC_DRIVER_NAME ": freq set to %dHz\n", freq); else printk(LIRC_DRIVER_NAME ": freq unchanged\n"); }
static void net_cb (EV_P_ ev_io *w, int revents) { if(http_response_process(NULL)) { net_io=0; if((resp_ret.type==REQ_SUBMIT)&&(!resp_ret.result)) { http_request(REQ_QUERY); net_io=1; status=WAIT; } else { status=READY; update_display("default.png",0); } write_to_usb(resp_ret.type,resp_ret.type); } ghttp_flush_response_buffer(request); ev_break (EV_A_ EVBREAK_ALL); }
static ssize_t lirc_write(struct file *file, const char *buf, size_t n, loff_t *ppos) { int i, count; unsigned int mod_signal_length = 0; unsigned int time_elapse = 0; unsigned int total_time_elapsed = 0; unsigned int num_bytes_already_sent = 0; unsigned int hibyte = 0; unsigned int lobyte = 0; int cmdir_cnt = 0; unsigned int wait_this = 0; struct timeval start_time; struct timeval end_time; unsigned int real_time_elapsed = 0; /* save the time we started the write: */ do_gettimeofday(&start_time); if (n % sizeof(lirc_t)) return -EINVAL; count = n/sizeof(lirc_t); if (count > WBUF_LEN || count % 2 == 0) return -EINVAL; if (copy_from_user(wbuf, buf, n)) return -EFAULT; /* * the first time we have to flag that this is the start of a new * signal otherwise COMMANDIR may receive 2 back-to-back pulses & * invert the signal */ cmdir_char[0] = TX_HEADER_NEW; signal_num++; cmdir_char[1] = signal_num; cmdir_cnt = 2; for (i = 0; i < count; i++) { /* conversion to number of modulation frequency pulse edges */ mod_signal_length = wbuf[i] >> 3; /* * account for minor rounding errors - * calculate length from this: */ time_elapse += mod_signal_length * timerval; hibyte = mod_signal_length / 256; lobyte = mod_signal_length % 256; cmdir_char[cmdir_cnt+1] = lobyte; cmdir_char[cmdir_cnt] = hibyte; cmdir_cnt += 2; /* write data to usb if full packet is collected */ if (cmdir_cnt % MAX_PACKET == 0) { write_to_usb(cmdir_char, MAX_PACKET, time_elapse); total_time_elapsed += time_elapse; num_bytes_already_sent += MAX_PACKET; time_elapse = 0; if ((i + 1) < count) { /* still more to send: */ cmdir_char[0] = TX_HEADER; /* Next Packet */ cmdir_char[1] = signal_num; cmdir_cnt = 2; /* reset the count */ } } } /* send last chunk of data */ if (cmdir_cnt > 0) { total_time_elapsed += time_elapse; write_to_usb(cmdir_char, cmdir_cnt, time_elapse); } /* XXX ERS remove all this? */ /* * we need to _manually delay ourselves_ to remain backwards * compatible with LIRC and prevent our queue buffer from overflowing. * Queuing in this driver is about instant, and send_start for example * will fill it up quickly and prevent send_stop from taking immediate * effect. */ dprintk("Total elapsed time is: %d. \n", total_time_elapsed); do_gettimeofday(&end_time); /* * udelay for the difference between endtime and * start + total_time_elapsed */ if (start_time.tv_usec < end_time.tv_usec) real_time_elapsed = (end_time.tv_usec - start_time.tv_usec); else real_time_elapsed = ((end_time.tv_usec + 1000000) - start_time.tv_usec); dprintk("Real time elapsed was %u.\n", real_time_elapsed); if (real_time_elapsed < (total_time_elapsed - 1000)) wait_this = total_time_elapsed - real_time_elapsed - 1000; #if 0 /* enable this for backwards compatibility */ safe_udelay(wait_this); #endif return(n); }