diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2013-06-21 02:55:33 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-07-31 14:43:56 -0400 |
commit | 477c1cfe8f8050ce716b3d89be17b33a4a80fc9d (patch) | |
tree | ca2e4dd232ce5b2d37a2587766615a64c2ec34f7 /drivers/media/platform/coda.c | |
parent | 8358e76c14ab4103f27bf2258fbf6dae4cceac8b (diff) |
[media] coda: split encoder specific parts out of device_run and irq_handler
Add coda_prepare_encode() and coda_finish_encode() functions. They are called
from coda_device_run() and coda_irq_handler(), respectively, before and after
the hardware picture run. This should make the following decoder support patch
easier to read, which will add the coda_prepare/finish_decode() equivalents.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/platform/coda.c')
-rw-r--r-- | drivers/media/platform/coda.c | 82 |
1 files changed, 48 insertions, 34 deletions
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 8575b713320e..2c37e3d18259 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c | |||
@@ -802,9 +802,8 @@ static void coda_fill_bitstream(struct coda_ctx *ctx) | |||
802 | /* | 802 | /* |
803 | * Mem-to-mem operations. | 803 | * Mem-to-mem operations. |
804 | */ | 804 | */ |
805 | static void coda_device_run(void *m2m_priv) | 805 | static void coda_prepare_encode(struct coda_ctx *ctx) |
806 | { | 806 | { |
807 | struct coda_ctx *ctx = m2m_priv; | ||
808 | struct coda_q_data *q_data_src, *q_data_dst; | 807 | struct coda_q_data *q_data_src, *q_data_dst; |
809 | struct vb2_buffer *src_buf, *dst_buf; | 808 | struct vb2_buffer *src_buf, *dst_buf; |
810 | struct coda_dev *dev = ctx->dev; | 809 | struct coda_dev *dev = ctx->dev; |
@@ -814,8 +813,6 @@ static void coda_device_run(void *m2m_priv) | |||
814 | u32 pic_stream_buffer_addr, pic_stream_buffer_size; | 813 | u32 pic_stream_buffer_addr, pic_stream_buffer_size; |
815 | u32 dst_fourcc; | 814 | u32 dst_fourcc; |
816 | 815 | ||
817 | mutex_lock(&dev->coda_mutex); | ||
818 | |||
819 | src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx); | 816 | src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx); |
820 | dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); | 817 | dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); |
821 | q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); | 818 | q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); |
@@ -926,6 +923,16 @@ static void coda_device_run(void *m2m_priv) | |||
926 | coda_write(dev, pic_stream_buffer_addr, CODA_CMD_ENC_PIC_BB_START); | 923 | coda_write(dev, pic_stream_buffer_addr, CODA_CMD_ENC_PIC_BB_START); |
927 | coda_write(dev, pic_stream_buffer_size / 1024, | 924 | coda_write(dev, pic_stream_buffer_size / 1024, |
928 | CODA_CMD_ENC_PIC_BB_SIZE); | 925 | CODA_CMD_ENC_PIC_BB_SIZE); |
926 | } | ||
927 | |||
928 | static void coda_device_run(void *m2m_priv) | ||
929 | { | ||
930 | struct coda_ctx *ctx = m2m_priv; | ||
931 | struct coda_dev *dev = ctx->dev; | ||
932 | |||
933 | mutex_lock(&dev->coda_mutex); | ||
934 | |||
935 | coda_prepare_encode(ctx); | ||
929 | 936 | ||
930 | if (dev->devtype->product == CODA_7541) { | 937 | if (dev->devtype->product == CODA_7541) { |
931 | coda_write(dev, CODA7_USE_BIT_ENABLE | CODA7_USE_HOST_BIT_ENABLE | | 938 | coda_write(dev, CODA7_USE_BIT_ENABLE | CODA7_USE_HOST_BIT_ENABLE | |
@@ -2034,39 +2041,11 @@ static const struct v4l2_file_operations coda_fops = { | |||
2034 | .mmap = coda_mmap, | 2041 | .mmap = coda_mmap, |
2035 | }; | 2042 | }; |
2036 | 2043 | ||
2037 | static irqreturn_t coda_irq_handler(int irq, void *data) | 2044 | static void coda_encode_finish(struct coda_ctx *ctx) |
2038 | { | 2045 | { |
2039 | struct vb2_buffer *src_buf, *dst_buf; | 2046 | struct vb2_buffer *src_buf, *dst_buf; |
2040 | struct coda_dev *dev = data; | 2047 | struct coda_dev *dev = ctx->dev; |
2041 | u32 wr_ptr, start_ptr; | 2048 | u32 wr_ptr, start_ptr; |
2042 | struct coda_ctx *ctx; | ||
2043 | |||
2044 | cancel_delayed_work(&dev->timeout); | ||
2045 | |||
2046 | /* read status register to attend the IRQ */ | ||
2047 | coda_read(dev, CODA_REG_BIT_INT_STATUS); | ||
2048 | coda_write(dev, CODA_REG_BIT_INT_CLEAR_SET, | ||
2049 | CODA_REG_BIT_INT_CLEAR); | ||
2050 | |||
2051 | ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev); | ||
2052 | if (ctx == NULL) { | ||
2053 | v4l2_err(&dev->v4l2_dev, "Instance released before the end of transaction\n"); | ||
2054 | mutex_unlock(&dev->coda_mutex); | ||
2055 | return IRQ_HANDLED; | ||
2056 | } | ||
2057 | |||
2058 | if (ctx->aborting) { | ||
2059 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, | ||
2060 | "task has been aborted\n"); | ||
2061 | mutex_unlock(&dev->coda_mutex); | ||
2062 | return IRQ_HANDLED; | ||
2063 | } | ||
2064 | |||
2065 | if (coda_isbusy(ctx->dev)) { | ||
2066 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, | ||
2067 | "coda is still busy!!!!\n"); | ||
2068 | return IRQ_NONE; | ||
2069 | } | ||
2070 | 2049 | ||
2071 | src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); | 2050 | src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); |
2072 | dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); | 2051 | dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); |
@@ -2115,6 +2094,41 @@ static irqreturn_t coda_irq_handler(int irq, void *data) | |||
2115 | dst_buf->v4l2_buf.sequence, | 2094 | dst_buf->v4l2_buf.sequence, |
2116 | (dst_buf->v4l2_buf.flags & V4L2_BUF_FLAG_KEYFRAME) ? | 2095 | (dst_buf->v4l2_buf.flags & V4L2_BUF_FLAG_KEYFRAME) ? |
2117 | "KEYFRAME" : "PFRAME"); | 2096 | "KEYFRAME" : "PFRAME"); |
2097 | } | ||
2098 | |||
2099 | static irqreturn_t coda_irq_handler(int irq, void *data) | ||
2100 | { | ||
2101 | struct coda_dev *dev = data; | ||
2102 | struct coda_ctx *ctx; | ||
2103 | |||
2104 | cancel_delayed_work(&dev->timeout); | ||
2105 | |||
2106 | /* read status register to attend the IRQ */ | ||
2107 | coda_read(dev, CODA_REG_BIT_INT_STATUS); | ||
2108 | coda_write(dev, CODA_REG_BIT_INT_CLEAR_SET, | ||
2109 | CODA_REG_BIT_INT_CLEAR); | ||
2110 | |||
2111 | ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev); | ||
2112 | if (ctx == NULL) { | ||
2113 | v4l2_err(&dev->v4l2_dev, "Instance released before the end of transaction\n"); | ||
2114 | mutex_unlock(&dev->coda_mutex); | ||
2115 | return IRQ_HANDLED; | ||
2116 | } | ||
2117 | |||
2118 | if (ctx->aborting) { | ||
2119 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, | ||
2120 | "task has been aborted\n"); | ||
2121 | mutex_unlock(&dev->coda_mutex); | ||
2122 | return IRQ_HANDLED; | ||
2123 | } | ||
2124 | |||
2125 | if (coda_isbusy(ctx->dev)) { | ||
2126 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, | ||
2127 | "coda is still busy!!!!\n"); | ||
2128 | return IRQ_NONE; | ||
2129 | } | ||
2130 | |||
2131 | coda_encode_finish(ctx); | ||
2118 | 2132 | ||
2119 | mutex_unlock(&dev->coda_mutex); | 2133 | mutex_unlock(&dev->coda_mutex); |
2120 | 2134 | ||