diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2012-01-27 19:47:47 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2012-01-27 20:08:33 +0100 |
commit | bf47e577aa7d5d6e64cb6b8a1f8869c62dc5d2f9 (patch) | |
tree | a97a0e8d5a8efceeb198ba06528294ed4484c64b | |
parent | 900b494a2710b3237f46929baf0eba26d8bc8292 (diff) |
imx233: implement dcp blitting, simplify code and make it work even in context interrupt by busy waiting
Change-Id: Ife949e13e3e04a56a2b5bc554eb46c726e719712
-rw-r--r-- | firmware/target/arm/imx233/dcp-imx233.c | 87 | ||||
-rw-r--r-- | firmware/target/arm/imx233/dcp-imx233.h | 8 |
2 files changed, 77 insertions, 18 deletions
diff --git a/firmware/target/arm/imx233/dcp-imx233.c b/firmware/target/arm/imx233/dcp-imx233.c index 565dba7691..f7849b183f 100644 --- a/firmware/target/arm/imx233/dcp-imx233.c +++ b/firmware/target/arm/imx233/dcp-imx233.c @@ -111,44 +111,98 @@ static enum imx233_dcp_error_t get_error_status(int ch) } } -enum imx233_dcp_error_t imx233_dcp_memcpy_ex(int ch, void *src, void *dst, size_t len) +static enum imx233_dcp_error_t imx233_dcp_job(int ch) { + /* if IRQs are not enabled, don't enable channel interrupt and do some polling */ + bool irq_enabled = irq_enabled(); /* enable channel, clear interrupt, enable interrupt */ imx233_enable_interrupt(INT_SRC_DCP, true); - __REG_SET(HW_DCP_CTRL) = HW_DCP_CTRL__CHANNEL_INTERRUPT_ENABLE(ch); + if(irq_enabled) + __REG_SET(HW_DCP_CTRL) = HW_DCP_CTRL__CHANNEL_INTERRUPT_ENABLE(ch); __REG_CLR(HW_DCP_STAT) = HW_DCP_STAT__IRQ(ch); __REG_SET(HW_DCP_CHANNELCTRL) = HW_DCP_CHANNELCTRL__ENABLE_CHANNEL(ch); + /* write back packet */ + commit_discard_dcache_range(&channel_packet[ch], sizeof(struct imx233_dcp_packet_t)); + /* write 1 to semaphore to run job */ + HW_DCP_CHxCMDPTR(ch) = (uint32_t)PHYSICAL_ADDR(&channel_packet[ch]); + HW_DCP_CHxSEMA(ch) = 1; + /* wait completion */ + if(irq_enabled) + semaphore_wait(&channel_sema[ch], TIMEOUT_BLOCK); + else + while(__XTRACT_EX(HW_DCP_CHxSEMA(ch), HW_DCP_CHxSEMA__VALUE)) + udelay(10); + /* disable channel and interrupt */ + __REG_CLR(HW_DCP_CTRL) = HW_DCP_CTRL__CHANNEL_INTERRUPT_ENABLE(ch); + __REG_CLR(HW_DCP_CHANNELCTRL) = HW_DCP_CHANNELCTRL__ENABLE_CHANNEL(ch); + /* read status */ + return get_error_status(ch); +} + + +enum imx233_dcp_error_t imx233_dcp_memcpy_ex(int ch, bool fill, const void *src, void *dst, size_t len) +{ /* prepare packet */ channel_packet[ch].next = 0; channel_packet[ch].ctrl0 = HW_DCP_CTRL0__INTERRUPT_ENABLE | - HW_DCP_CTRL0__ENABLE_MEMCOPY | HW_DCP_CTRL0__DECR_SEMAPHORE; + HW_DCP_CTRL0__ENABLE_MEMCOPY | HW_DCP_CTRL0__DECR_SEMAPHORE | + (fill ? HW_DCP_CTRL0__CONSTANT_FILL : 0); channel_packet[ch].ctrl1 = 0; - channel_packet[ch].src = (uint32_t)PHYSICAL_ADDR(src); + channel_packet[ch].src = (uint32_t)(fill ? src : PHYSICAL_ADDR(src)); channel_packet[ch].dst = (uint32_t)PHYSICAL_ADDR(dst); channel_packet[ch].size = len; channel_packet[ch].payload = 0; channel_packet[ch].status = 0; - /* write-back src, discard dst, write-back packet */ - commit_discard_dcache_range(src, len); + /* write-back src if not filling, discard dst */ + if(!fill) + commit_discard_dcache_range(src, len); discard_dcache_range(dst, len); - commit_discard_dcache_range(&channel_packet[ch], sizeof(struct imx233_dcp_packet_t)); - /* write 1 to semaphore to run job */ - HW_DCP_CHxCMDPTR(ch) = (uint32_t)PHYSICAL_ADDR(&channel_packet[ch]); - HW_DCP_CHxSEMA(ch) = 1; - /* wait completion */ - semaphore_wait(&channel_sema[ch], TIMEOUT_BLOCK); - /* read status */ - return get_error_status(ch); + + /* do the job */ + return imx233_dcp_job(ch); +} + +enum imx233_dcp_error_t imx233_dcp_memcpy(bool fill, const void *src, void *dst, size_t len, int tmo) +{ + int chan = imx233_dcp_acquire_channel(tmo); + if(chan == OBJ_WAIT_TIMEDOUT) + return DCP_TIMEOUT; + enum imx233_dcp_error_t err = imx233_dcp_memcpy_ex(chan, fill, src, dst, len); + imx233_dcp_release_channel(chan); + return err; +} + +enum imx233_dcp_error_t imx233_dcp_blit_ex(int ch, bool fill, const void *src, size_t w, size_t h, void *dst, size_t out_w) +{ + /* prepare packet */ + channel_packet[ch].next = 0; + channel_packet[ch].ctrl0 = HW_DCP_CTRL0__INTERRUPT_ENABLE | + HW_DCP_CTRL0__ENABLE_MEMCOPY | HW_DCP_CTRL0__DECR_SEMAPHORE | + HW_DCP_CTRL0__ENABLE_BLIT | + (fill ? HW_DCP_CTRL0__CONSTANT_FILL : 0); + channel_packet[ch].ctrl1 = out_w; + channel_packet[ch].src = (uint32_t)(fill ? src : PHYSICAL_ADDR(src)); + channel_packet[ch].dst = (uint32_t)PHYSICAL_ADDR(dst); + channel_packet[ch].size = w | h << HW_DCP_SIZE__NUMBER_LINES_BP; + channel_packet[ch].payload = 0; + channel_packet[ch].status = 0; + + /* we have a problem here to discard the output buffer since it's not contiguous + * so only commit the source */ + if(!fill) + commit_discard_dcache_range(src, w * h); + /* do the job */ + return imx233_dcp_job(ch); } -enum imx233_dcp_error_t imx233_dcp_memcpy(void *src, void *dst, size_t len, int tmo) +enum imx233_dcp_error_t imx233_dcp_blit(bool fill, const void *src, size_t w, size_t h, void *dst, size_t out_w, int tmo) { int chan = imx233_dcp_acquire_channel(tmo); if(chan == OBJ_WAIT_TIMEDOUT) return DCP_TIMEOUT; - enum imx233_dcp_error_t err = imx233_dcp_memcpy_ex(chan, src, dst, len); + enum imx233_dcp_error_t err = imx233_dcp_blit_ex(chan, fill, src, w, h, dst, out_w); imx233_dcp_release_channel(chan); return err; } @@ -185,6 +239,7 @@ struct imx233_dcp_info_t imx233_dcp_get_info(unsigned flags) info.channel[i].enable = HW_DCP_CHANNELCTRL & HW_DCP_CHANNELCTRL__ENABLE_CHANNEL(i); info.channel[i].sema = __XTRACT_EX(HW_DCP_CHxSEMA(i), HW_DCP_CHxSEMA__VALUE); info.channel[i].cmdptr = HW_DCP_CHxCMDPTR(i); + info.channel[i].acquired = arbiter_acquired(&channel_arbiter, i); } } if(flags & DCP_INFO_CSC) diff --git a/firmware/target/arm/imx233/dcp-imx233.h b/firmware/target/arm/imx233/dcp-imx233.h index 375da16c04..b8340fb4f0 100644 --- a/firmware/target/arm/imx233/dcp-imx233.h +++ b/firmware/target/arm/imx233/dcp-imx233.h @@ -295,6 +295,7 @@ struct imx233_dcp_channel_info_t bool ready; int sema; uint32_t cmdptr; + bool acquired; }; struct imx233_dcp_csc_info_t @@ -355,8 +356,11 @@ void imx233_dcp_release_channel(int chan); // doesn't check that channel is in use! void imx233_dcp_reserve_channel(int channel); -enum imx233_dcp_error_t imx233_dcp_memcpy_ex(int channel, void *src, void *dst, size_t len); -enum imx233_dcp_error_t imx233_dcp_memcpy(void *src, void *dst, size_t len, int tmo); +enum imx233_dcp_error_t imx233_dcp_memcpy_ex(int channel, bool fill, const void *src, void *dst, size_t len); +enum imx233_dcp_error_t imx233_dcp_memcpy(bool fill, const void *src, void *dst, size_t len, int tmo); + +enum imx233_dcp_error_t imx233_dcp_blit_ex(int channel, bool fill, const void *src, size_t w, size_t h, void *dst, size_t out_w); +enum imx233_dcp_error_t imx233_dcp_blit(bool fill, const void *src, size_t w, size_t h, void *dst, size_t out_w, int tmo); struct imx233_dcp_info_t imx233_dcp_get_info(unsigned flags); |