1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
6 * Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
7 * Copyright (C) 2018 Bootlin
9 * Based on the vim2m driver, that is:
11 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
12 * Pawel Osciak, <pawel@osciak.com>
13 * Marek Szyprowski, <m.szyprowski@samsung.com>
16 #include <media/v4l2-device.h>
17 #include <media/v4l2-ioctl.h>
18 #include <media/v4l2-event.h>
19 #include <media/v4l2-mem2mem.h>
22 #include "cedrus_dec.h"
23 #include "cedrus_hw.h"
25 void cedrus_device_run(void *priv)
27 struct cedrus_ctx *ctx = priv;
28 struct cedrus_dev *dev = ctx->dev;
29 struct cedrus_run run = { 0 };
30 struct media_request *src_req;
33 run.src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
34 run.dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
36 /* Apply request(s) controls if needed. */
37 src_req = run.src->vb2_buf.req_obj.req;
40 v4l2_ctrl_request_setup(src_req, &ctx->hdl);
42 spin_lock_irqsave(&ctx->dev->irq_lock, flags);
44 switch (ctx->src_fmt.pixelformat) {
45 case V4L2_PIX_FMT_MPEG2_SLICE:
46 run.mpeg2.slice_params = cedrus_find_control_data(ctx,
47 V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS);
48 run.mpeg2.quantization = cedrus_find_control_data(ctx,
49 V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION);
56 dev->dec_ops[ctx->current_codec]->setup(ctx, &run);
58 spin_unlock_irqrestore(&ctx->dev->irq_lock, flags);
60 /* Complete request(s) controls if needed. */
63 v4l2_ctrl_request_complete(src_req, &ctx->hdl);
65 spin_lock_irqsave(&ctx->dev->irq_lock, flags);
67 dev->dec_ops[ctx->current_codec]->trigger(ctx);
69 spin_unlock_irqrestore(&ctx->dev->irq_lock, flags);