int bs_wr_dat(bool which, u32 data_size, u16 *data) { int result; if ( USE_WR_BUF(data_size) ) result = bs_io_buf(data_size, data, BS_WR); else { int i; result = EINKFB_SUCCESS; for ( i = 0; (i < data_size) && (EINKFB_SUCCESS == result); i++ ) { if ( BS_WR_DAT_DATA == which ) { if ( EINKFB_DEBUG() && (9 > i) ) einkfb_debug_full("data[%d] = 0x%04X\n", i, data[i]); } else einkfb_debug_full("args[%d] = 0x%04X\n", i, data[i]); result = bs_wr_which(BS_DAT, (uint32_t)data[i]); } } return ( result ); }
// 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 ); }
int bs_wr_cmd(bs_cmd cmd, bool poll) { int result; einkfb_debug_full("command = 0x%04X, poll = %d\n", cmd, poll); result = bs_wr_which(BS_CMD, (uint32_t)cmd); if ( (EINKFB_SUCCESS == result) && poll ) { if ( !BS_READY() ) result = EINKFB_FAILURE; } 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 ); }
int bs_rd_dat(u32 data_size, u16 *data) { int result = EINKFB_FAILURE; // For single-word reads, don't use the buffer call. // if ( !USE_RD_BUF(data_size) ) result = bs_rd_one(data); else { einkfb_debug_full("size = %d\n", data_size); if ( BS_READY() ) result = bs_io_buf(data_size, data, BS_RD); } return ( result ); }