aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/platform/s5p-mfc/s5p_mfc_enc.c')
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c67
1 files changed, 23 insertions, 44 deletions
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index d26b2484ca10..a904a1c7bb21 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -739,14 +739,11 @@ static int s5p_mfc_ctx_ready(struct s5p_mfc_ctx *ctx)
739static void cleanup_ref_queue(struct s5p_mfc_ctx *ctx) 739static void cleanup_ref_queue(struct s5p_mfc_ctx *ctx)
740{ 740{
741 struct s5p_mfc_buf *mb_entry; 741 struct s5p_mfc_buf *mb_entry;
742 unsigned long mb_y_addr, mb_c_addr;
743 742
744 /* move buffers in ref queue to src queue */ 743 /* move buffers in ref queue to src queue */
745 while (!list_empty(&ctx->ref_queue)) { 744 while (!list_empty(&ctx->ref_queue)) {
746 mb_entry = list_entry((&ctx->ref_queue)->next, 745 mb_entry = list_entry((&ctx->ref_queue)->next,
747 struct s5p_mfc_buf, list); 746 struct s5p_mfc_buf, list);
748 mb_y_addr = vb2_dma_contig_plane_dma_addr(mb_entry->b, 0);
749 mb_c_addr = vb2_dma_contig_plane_dma_addr(mb_entry->b, 1);
750 list_del(&mb_entry->list); 747 list_del(&mb_entry->list);
751 ctx->ref_queue_cnt--; 748 ctx->ref_queue_cnt--;
752 list_add_tail(&mb_entry->list, &ctx->src_queue); 749 list_add_tail(&mb_entry->list, &ctx->src_queue);
@@ -770,7 +767,7 @@ static int enc_pre_seq_start(struct s5p_mfc_ctx *ctx)
770 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); 767 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
771 dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0); 768 dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0);
772 dst_size = vb2_plane_size(dst_mb->b, 0); 769 dst_size = vb2_plane_size(dst_mb->b, 0);
773 s5p_mfc_hw_call(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr, 770 s5p_mfc_hw_call_void(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr,
774 dst_size); 771 dst_size);
775 spin_unlock_irqrestore(&dev->irqlock, flags); 772 spin_unlock_irqrestore(&dev->irqlock, flags);
776 return 0; 773 return 0;
@@ -803,7 +800,7 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
803 ctx->state = MFCINST_RUNNING; 800 ctx->state = MFCINST_RUNNING;
804 if (s5p_mfc_ctx_ready(ctx)) 801 if (s5p_mfc_ctx_ready(ctx))
805 set_work_bit_irqsave(ctx); 802 set_work_bit_irqsave(ctx);
806 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); 803 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
807 } else { 804 } else {
808 enc_pb_count = s5p_mfc_hw_call(dev->mfc_ops, 805 enc_pb_count = s5p_mfc_hw_call(dev->mfc_ops,
809 get_enc_dpb_count, dev); 806 get_enc_dpb_count, dev);
@@ -828,15 +825,15 @@ static int enc_pre_frame_start(struct s5p_mfc_ctx *ctx)
828 src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); 825 src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
829 src_y_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 0); 826 src_y_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 0);
830 src_c_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 1); 827 src_c_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 1);
831 s5p_mfc_hw_call(dev->mfc_ops, set_enc_frame_buffer, ctx, src_y_addr, 828 s5p_mfc_hw_call_void(dev->mfc_ops, set_enc_frame_buffer, ctx,
832 src_c_addr); 829 src_y_addr, src_c_addr);
833 spin_unlock_irqrestore(&dev->irqlock, flags); 830 spin_unlock_irqrestore(&dev->irqlock, flags);
834 831
835 spin_lock_irqsave(&dev->irqlock, flags); 832 spin_lock_irqsave(&dev->irqlock, flags);
836 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); 833 dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list);
837 dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0); 834 dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0);
838 dst_size = vb2_plane_size(dst_mb->b, 0); 835 dst_size = vb2_plane_size(dst_mb->b, 0);
839 s5p_mfc_hw_call(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr, 836 s5p_mfc_hw_call_void(dev->mfc_ops, set_enc_stream_buffer, ctx, dst_addr,
840 dst_size); 837 dst_size);
841 spin_unlock_irqrestore(&dev->irqlock, flags); 838 spin_unlock_irqrestore(&dev->irqlock, flags);
842 839
@@ -861,7 +858,7 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
861 mfc_read(dev, S5P_FIMV_ENC_SI_PIC_CNT)); 858 mfc_read(dev, S5P_FIMV_ENC_SI_PIC_CNT));
862 spin_lock_irqsave(&dev->irqlock, flags); 859 spin_lock_irqsave(&dev->irqlock, flags);
863 if (slice_type >= 0) { 860 if (slice_type >= 0) {
864 s5p_mfc_hw_call(dev->mfc_ops, get_enc_frame_buffer, ctx, 861 s5p_mfc_hw_call_void(dev->mfc_ops, get_enc_frame_buffer, ctx,
865 &enc_y_addr, &enc_c_addr); 862 &enc_y_addr, &enc_c_addr);
866 list_for_each_entry(mb_entry, &ctx->src_queue, list) { 863 list_for_each_entry(mb_entry, &ctx->src_queue, list) {
867 mb_y_addr = vb2_dma_contig_plane_dma_addr(mb_entry->b, 0); 864 mb_y_addr = vb2_dma_contig_plane_dma_addr(mb_entry->b, 0);
@@ -954,17 +951,13 @@ static int vidioc_querycap(struct file *file, void *priv,
954} 951}
955 952
956static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f, 953static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
957 bool mplane, bool out) 954 bool out)
958{ 955{
959 struct s5p_mfc_dev *dev = video_drvdata(file); 956 struct s5p_mfc_dev *dev = video_drvdata(file);
960 struct s5p_mfc_fmt *fmt; 957 struct s5p_mfc_fmt *fmt;
961 int i, j = 0; 958 int i, j = 0;
962 959
963 for (i = 0; i < ARRAY_SIZE(formats); ++i) { 960 for (i = 0; i < ARRAY_SIZE(formats); ++i) {
964 if (mplane && formats[i].num_planes == 1)
965 continue;
966 else if (!mplane && formats[i].num_planes > 1)
967 continue;
968 if (out && formats[i].type != MFC_FMT_RAW) 961 if (out && formats[i].type != MFC_FMT_RAW)
969 continue; 962 continue;
970 else if (!out && formats[i].type != MFC_FMT_ENC) 963 else if (!out && formats[i].type != MFC_FMT_ENC)
@@ -984,28 +977,16 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
984 return -EINVAL; 977 return -EINVAL;
985} 978}
986 979
987static int vidioc_enum_fmt_vid_cap(struct file *file, void *pirv,
988 struct v4l2_fmtdesc *f)
989{
990 return vidioc_enum_fmt(file, f, false, false);
991}
992
993static int vidioc_enum_fmt_vid_cap_mplane(struct file *file, void *pirv, 980static int vidioc_enum_fmt_vid_cap_mplane(struct file *file, void *pirv,
994 struct v4l2_fmtdesc *f) 981 struct v4l2_fmtdesc *f)
995{ 982{
996 return vidioc_enum_fmt(file, f, true, false); 983 return vidioc_enum_fmt(file, f, false);
997}
998
999static int vidioc_enum_fmt_vid_out(struct file *file, void *prov,
1000 struct v4l2_fmtdesc *f)
1001{
1002 return vidioc_enum_fmt(file, f, false, true);
1003} 984}
1004 985
1005static int vidioc_enum_fmt_vid_out_mplane(struct file *file, void *prov, 986static int vidioc_enum_fmt_vid_out_mplane(struct file *file, void *prov,
1006 struct v4l2_fmtdesc *f) 987 struct v4l2_fmtdesc *f)
1007{ 988{
1008 return vidioc_enum_fmt(file, f, true, true); 989 return vidioc_enum_fmt(file, f, true);
1009} 990}
1010 991
1011static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f) 992static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
@@ -1127,7 +1108,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
1127 pix_fmt_mp->width, pix_fmt_mp->height, 1108 pix_fmt_mp->width, pix_fmt_mp->height,
1128 ctx->img_width, ctx->img_height); 1109 ctx->img_width, ctx->img_height);
1129 1110
1130 s5p_mfc_hw_call(dev->mfc_ops, enc_calc_src_size, ctx); 1111 s5p_mfc_hw_call_void(dev->mfc_ops, enc_calc_src_size, ctx);
1131 pix_fmt_mp->plane_fmt[0].sizeimage = ctx->luma_size; 1112 pix_fmt_mp->plane_fmt[0].sizeimage = ctx->luma_size;
1132 pix_fmt_mp->plane_fmt[0].bytesperline = ctx->buf_width; 1113 pix_fmt_mp->plane_fmt[0].bytesperline = ctx->buf_width;
1133 pix_fmt_mp->plane_fmt[1].sizeimage = ctx->chroma_size; 1114 pix_fmt_mp->plane_fmt[1].sizeimage = ctx->chroma_size;
@@ -1681,8 +1662,8 @@ static int vidioc_g_parm(struct file *file, void *priv,
1681 return 0; 1662 return 0;
1682} 1663}
1683 1664
1684int vidioc_encoder_cmd(struct file *file, void *priv, 1665static int vidioc_encoder_cmd(struct file *file, void *priv,
1685 struct v4l2_encoder_cmd *cmd) 1666 struct v4l2_encoder_cmd *cmd)
1686{ 1667{
1687 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv); 1668 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
1688 struct s5p_mfc_dev *dev = ctx->dev; 1669 struct s5p_mfc_dev *dev = ctx->dev;
@@ -1704,7 +1685,7 @@ int vidioc_encoder_cmd(struct file *file, void *priv,
1704 if (s5p_mfc_ctx_ready(ctx)) 1685 if (s5p_mfc_ctx_ready(ctx))
1705 set_work_bit_irqsave(ctx); 1686 set_work_bit_irqsave(ctx);
1706 spin_unlock_irqrestore(&dev->irqlock, flags); 1687 spin_unlock_irqrestore(&dev->irqlock, flags);
1707 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); 1688 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
1708 } else { 1689 } else {
1709 mfc_debug(2, "EOS: marking last buffer of stream\n"); 1690 mfc_debug(2, "EOS: marking last buffer of stream\n");
1710 buf = list_entry(ctx->src_queue.prev, 1691 buf = list_entry(ctx->src_queue.prev,
@@ -1736,9 +1717,7 @@ static int vidioc_subscribe_event(struct v4l2_fh *fh,
1736 1717
1737static const struct v4l2_ioctl_ops s5p_mfc_enc_ioctl_ops = { 1718static const struct v4l2_ioctl_ops s5p_mfc_enc_ioctl_ops = {
1738 .vidioc_querycap = vidioc_querycap, 1719 .vidioc_querycap = vidioc_querycap,
1739 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1740 .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, 1720 .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane,
1741 .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out,
1742 .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, 1721 .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane,
1743 .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt, 1722 .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt,
1744 .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt, 1723 .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt,
@@ -1771,13 +1750,13 @@ static int check_vb_with_fmt(struct s5p_mfc_fmt *fmt, struct vb2_buffer *vb)
1771 return -EINVAL; 1750 return -EINVAL;
1772 } 1751 }
1773 for (i = 0; i < fmt->num_planes; i++) { 1752 for (i = 0; i < fmt->num_planes; i++) {
1774 if (!vb2_dma_contig_plane_dma_addr(vb, i)) { 1753 dma_addr_t dma = vb2_dma_contig_plane_dma_addr(vb, i);
1754 if (!dma) {
1775 mfc_err("failed to get plane cookie\n"); 1755 mfc_err("failed to get plane cookie\n");
1776 return -EINVAL; 1756 return -EINVAL;
1777 } 1757 }
1778 mfc_debug(2, "index: %d, plane[%d] cookie: 0x%08zx\n", 1758 mfc_debug(2, "index: %d, plane[%d] cookie: %pad\n",
1779 vb->v4l2_buf.index, i, 1759 vb->v4l2_buf.index, i, &dma);
1780 vb2_dma_contig_plane_dma_addr(vb, i));
1781 } 1760 }
1782 return 0; 1761 return 0;
1783} 1762}
@@ -1897,7 +1876,7 @@ static int s5p_mfc_buf_prepare(struct vb2_buffer *vb)
1897 ret = check_vb_with_fmt(ctx->dst_fmt, vb); 1876 ret = check_vb_with_fmt(ctx->dst_fmt, vb);
1898 if (ret < 0) 1877 if (ret < 0)
1899 return ret; 1878 return ret;
1900 mfc_debug(2, "plane size: %ld, dst size: %d\n", 1879 mfc_debug(2, "plane size: %ld, dst size: %zu\n",
1901 vb2_plane_size(vb, 0), ctx->enc_dst_buf_size); 1880 vb2_plane_size(vb, 0), ctx->enc_dst_buf_size);
1902 if (vb2_plane_size(vb, 0) < ctx->enc_dst_buf_size) { 1881 if (vb2_plane_size(vb, 0) < ctx->enc_dst_buf_size) {
1903 mfc_err("plane size is too small for capture\n"); 1882 mfc_err("plane size is too small for capture\n");
@@ -1948,7 +1927,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
1948 /* If context is ready then dev = work->data;schedule it to run */ 1927 /* If context is ready then dev = work->data;schedule it to run */
1949 if (s5p_mfc_ctx_ready(ctx)) 1928 if (s5p_mfc_ctx_ready(ctx))
1950 set_work_bit_irqsave(ctx); 1929 set_work_bit_irqsave(ctx);
1951 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); 1930 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
1952 1931
1953 return 0; 1932 return 0;
1954} 1933}
@@ -1969,14 +1948,14 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
1969 ctx->state = MFCINST_FINISHED; 1948 ctx->state = MFCINST_FINISHED;
1970 spin_lock_irqsave(&dev->irqlock, flags); 1949 spin_lock_irqsave(&dev->irqlock, flags);
1971 if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 1950 if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
1972 s5p_mfc_hw_call(dev->mfc_ops, cleanup_queue, &ctx->dst_queue, 1951 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue,
1973 &ctx->vq_dst); 1952 &ctx->dst_queue, &ctx->vq_dst);
1974 INIT_LIST_HEAD(&ctx->dst_queue); 1953 INIT_LIST_HEAD(&ctx->dst_queue);
1975 ctx->dst_queue_cnt = 0; 1954 ctx->dst_queue_cnt = 0;
1976 } 1955 }
1977 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 1956 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1978 cleanup_ref_queue(ctx); 1957 cleanup_ref_queue(ctx);
1979 s5p_mfc_hw_call(dev->mfc_ops, cleanup_queue, &ctx->src_queue, 1958 s5p_mfc_hw_call_void(dev->mfc_ops, cleanup_queue, &ctx->src_queue,
1980 &ctx->vq_src); 1959 &ctx->vq_src);
1981 INIT_LIST_HEAD(&ctx->src_queue); 1960 INIT_LIST_HEAD(&ctx->src_queue);
1982 ctx->src_queue_cnt = 0; 1961 ctx->src_queue_cnt = 0;
@@ -2017,7 +1996,7 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
2017 } 1996 }
2018 if (s5p_mfc_ctx_ready(ctx)) 1997 if (s5p_mfc_ctx_ready(ctx))
2019 set_work_bit_irqsave(ctx); 1998 set_work_bit_irqsave(ctx);
2020 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); 1999 s5p_mfc_hw_call_void(dev->mfc_ops, try_run, dev);
2021} 2000}
2022 2001
2023static struct vb2_ops s5p_mfc_enc_qops = { 2002static struct vb2_ops s5p_mfc_enc_qops = {