media: hantro: Add helpers to prepare/finish a run
[linux-2.6-microblaze.git] / drivers / staging / media / hantro / hantro_drv.c
index c3665f0..4af6ee8 100644 (file)
@@ -153,6 +153,28 @@ void hantro_watchdog(struct work_struct *work)
        }
 }
 
+void hantro_prepare_run(struct hantro_ctx *ctx)
+{
+       struct vb2_v4l2_buffer *src_buf;
+
+       src_buf = hantro_get_src_buf(ctx);
+       v4l2_ctrl_request_setup(src_buf->vb2_buf.req_obj.req,
+                               &ctx->ctrl_handler);
+}
+
+void hantro_finish_run(struct hantro_ctx *ctx)
+{
+       struct vb2_v4l2_buffer *src_buf;
+
+       src_buf = hantro_get_src_buf(ctx);
+       v4l2_ctrl_request_complete(src_buf->vb2_buf.req_obj.req,
+                                  &ctx->ctrl_handler);
+
+       /* Kick the watchdog. */
+       schedule_delayed_work(&ctx->dev->watchdog_work,
+                             msecs_to_jiffies(2000));
+}
+
 static void device_run(void *priv)
 {
        struct hantro_ctx *ctx = priv;
@@ -262,27 +284,31 @@ static const struct v4l2_ctrl_ops hantro_ctrl_ops = {
        .s_ctrl = hantro_s_ctrl,
 };
 
-static struct hantro_ctrl controls[] = {
+static const struct hantro_ctrl controls[] = {
        {
-               .id = V4L2_CID_JPEG_COMPRESSION_QUALITY,
                .codec = HANTRO_JPEG_ENCODER,
                .cfg = {
+                       .id = V4L2_CID_JPEG_COMPRESSION_QUALITY,
                        .min = 5,
                        .max = 100,
                        .step = 1,
                        .def = 50,
+                       .ops = &hantro_ctrl_ops,
                },
        }, {
-               .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
                .codec = HANTRO_MPEG2_DECODER,
                .cfg = {
-                       .elem_size = sizeof(struct v4l2_ctrl_mpeg2_slice_params),
+                       .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
                },
        }, {
-               .id = V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION,
                .codec = HANTRO_MPEG2_DECODER,
                .cfg = {
-                       .elem_size = sizeof(struct v4l2_ctrl_mpeg2_quantization),
+                       .id = V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION,
+               },
+       }, {
+               .codec = HANTRO_VP8_DECODER,
+               .cfg = {
+                       .id = V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER,
                },
        },
 };
@@ -298,22 +324,12 @@ static int hantro_ctrls_setup(struct hantro_dev *vpu,
        for (i = 0; i < num_ctrls; i++) {
                if (!(allowed_codecs & controls[i].codec))
                        continue;
-               if (!controls[i].cfg.elem_size) {
-                       v4l2_ctrl_new_std(&ctx->ctrl_handler,
-                                         &hantro_ctrl_ops,
-                                         controls[i].id, controls[i].cfg.min,
-                                         controls[i].cfg.max,
-                                         controls[i].cfg.step,
-                                         controls[i].cfg.def);
-               } else {
-                       controls[i].cfg.id = controls[i].id;
-                       v4l2_ctrl_new_custom(&ctx->ctrl_handler,
-                                            &controls[i].cfg, NULL);
-               }
 
+               v4l2_ctrl_new_custom(&ctx->ctrl_handler,
+                                    &controls[i].cfg, NULL);
                if (ctx->ctrl_handler.error) {
                        vpu_err("Adding control (%d) failed %d\n",
-                               controls[i].id,
+                               controls[i].cfg.id,
                                ctx->ctrl_handler.error);
                        v4l2_ctrl_handler_free(&ctx->ctrl_handler);
                        return ctx->ctrl_handler.error;
@@ -419,6 +435,7 @@ static const struct v4l2_file_operations hantro_fops = {
 static const struct of_device_id of_hantro_match[] = {
 #ifdef CONFIG_VIDEO_HANTRO_ROCKCHIP
        { .compatible = "rockchip,rk3399-vpu", .data = &rk3399_vpu_variant, },
+       { .compatible = "rockchip,rk3328-vpu", .data = &rk3328_vpu_variant, },
        { .compatible = "rockchip,rk3288-vpu", .data = &rk3288_vpu_variant, },
 #endif
        { /* sentinel */ }
@@ -724,6 +741,7 @@ static int hantro_probe(struct platform_device *pdev)
                dev_err(vpu->dev, "Could not set DMA coherent mask.\n");
                return ret;
        }
+       vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
 
        for (i = 0; i < vpu->variant->num_irqs; i++) {
                const char *irq_name = vpu->variant->irqs[i].name;