// Scheduled loop for doing IO on framebuffer-sized buffers. // static int bs_io_buf(u32 data_size, u16 *data, bool which) { // display_port_t disp = BROADSHEET_DISPLAY_NUMBER; int result = EINKFB_FAILURE; dd_printk("[D] len=%i\n", data_size); einkfb_debug_full("size = %d\n", data_size); if ( BS_READY() ) { int i = 0, j, length = (EINKFB_MEMCPY_MIN >> 1), num_loops = data_size/length, remainder = data_size % length; bool done = false; if ( 0 != num_loops ) einkfb_debug("num_loops @ %d bytes = %d, remainder = %d\n", (length << 1), num_loops, (remainder << 1)); result = EINKFB_SUCCESS; // Read/write EINKFB_MEMCPY_MIN bytes (hence, divide by 2) at a time. While // there are still bytes to read/write, yield the CPU. // do { if ( 0 >= num_loops ) length = remainder; for ( j = 0; j < length; j++) { if ( BS_WR == which ) // ipu_adc_write_cmd(disp, DAT, (uint32_t)data[i + j], 0, 0); ipu_adc_write_cmd(DAT, (uint32_t)data[i + j]); else // data[i + j] = (u16)(ipu_adc_read_data(disp) & 0x0000FFFF); data[i + j] = (u16)(ipu_adc_read_data() & 0x0000FFFF); } i += length; if ( i < data_size ) { EINKFB_SCHEDULE(); num_loops--; } else done = true; } while ( !done ); } return ( result ); }
static int bs_rd_one(u16 *data) { display_port_t disp = BROADSHEET_DISPLAY_NUMBER; int result = EINKFB_SUCCESS; if ( BS_READY() ) *data = (u16)(ipu_adc_read_data(disp) & 0x0000FFFF); else result = EINKFB_FAILURE; if ( EINKFB_SUCCESS == result ) einkfb_debug_full("data = 0x%04X\n", *data); return ( result ); }