Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 26th, 2013  |  syntax: C  |  size: 1.96 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void lcdif_schedule_continuous_refresh(void *buffer, unsigned w, unsigned h)
  2. {
  3.     logf("refresh %dx%d\n", w, h);
  4.  
  5.     lcdif_write_reg(0x36, w - 1);
  6.     lcdif_write_reg(0x37, 0);
  7.     lcdif_write_reg(0x38, h - 1);
  8.     lcdif_write_reg(0x39, 0);
  9.     lcdif_write_reg(0x20, 0);
  10.     lcdif_write_reg(0x21, 0);
  11.     lcdif_write_data(false, 0x22);
  12.     lcdif_wait_ready();
  13.     __REG_CLR(HW_LCDIF_CTRL) = HW_LCDIF_CTRL__WORD_LENGTH_BM;
  14.     __REG_CLR(HW_LCDIF_CTRL1) = HW_LCDIF_CTRL1__BYTE_PACKING_FORMAT_BM;
  15.     __REG_SET(HW_LCDIF_CTRL) = HW_LCDIF_CTRL__WORD_LENGTH_16_BIT;
  16.     __REG_SET(HW_LCDIF_CTRL1) = 0xf << HW_LCDIF_CTRL1__BYTE_PACKING_FORMAT_BP;
  17.     g_lcdif_word_length = HW_LCDIF_CTRL__WORD_LENGTH_16_BIT;
  18.     __REG_CLR(HW_LCDIF_CTRL) = HW_LCDIF_CTRL__INPUT_DATA_SWIZZLE_BM;
  19.     __REG_SET(HW_LCDIF_CTRL) = HW_LCDIF_CTRL__INPUT_DATA_SWIZZLE__NO_SWAP;
  20.  
  21.     HW_LCDIF_TRANSFER_COUNT = (h << 16) | w;
  22.  
  23.     int rem_size = w * h * 2;
  24.     for(int i = 0; i < NR_CMDS; i++)
  25.     {
  26.         int xfer_size = MIN(rem_size, IMX233_MAX_SINGLE_DMA_XFER_SIZE);
  27.         lcdif_dma[i].cmd.next = &lcdif_dma[(i + 1) % NR_CMDS].cmd;
  28.         lcdif_dma[i].cmd.buffer = buffer;
  29.         lcdif_dma[i].cmd.cmd = HW_APB_CHx_CMD__COMMAND__READ |
  30.             HW_APB_CHx_CMD__CHAIN |
  31.             xfer_size << HW_APB_CHx_CMD__XFER_COUNT_BP;
  32.         logf("rem_size=0x%x xfer_size=0x%x\n", rem_size, xfer_size);
  33.         logf("cmd[%d][0x%x] nxt=0x%x buf=0x%x cmd=0x%x\n", i,
  34.              (uint32_t)&lcdif_dma[i].cmd, lcdif_dma[i].cmd.next,
  35.              lcdif_dma[i].cmd.buffer, lcdif_dma[i].cmd.cmd);
  36.         rem_size -= xfer_size;
  37.         buffer += xfer_size;
  38.     }
  39.  
  40.     lcdif_dma[0].cmd.cmd |= 1 << HW_APB_CHx_CMD__CMDWORDS_BP;
  41.     lcdif_dma[0].ctrl = HW_LCDIF_CTRL__RUN | HW_LCDIF_CTRL__DATA_SELECT;
  42.     lcdif_dma[NR_CMDS - 1].cmd.cmd |= HW_APB_CHx_CMD__WAIT4ENDCMD;
  43.  
  44.     dma_clkgate_channel(APB_LCDIF, true);
  45.     dma_reset_channel(APB_LCDIF);
  46.     dma_start_command(APB_LCDIF, &lcdif_dma[0].cmd);
  47. }
clone this paste RAW Paste Data