forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (c) 2016 MediaTek Inc.
34 * Author: Daniel Hsiao <daniel.hsiao@mediatek.com>
45 * PoChun Lin <pochun.lin@mediatek.com>
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
156 */
167
178 #include <linux/interrupt.h>
....@@ -26,7 +17,6 @@
2617 #include "../venc_drv_base.h"
2718 #include "../venc_ipi_msg.h"
2819 #include "../venc_vpu_if.h"
29
-#include "mtk_vpu.h"
3020
3121 #define VENC_BITSTREAM_FRAME_SIZE 0x0098
3222 #define VENC_BITSTREAM_HEADER_LEN 0x00e8
....@@ -199,10 +189,12 @@
199189 if (i == VENC_VP8_VPU_WORK_BUF_RC_CODE ||
200190 i == VENC_VP8_VPU_WORK_BUF_RC_CODE2 ||
201191 i == VENC_VP8_VPU_WORK_BUF_RC_CODE3) {
192
+ struct mtk_vcodec_fw *handler;
202193 void *tmp_va;
203194
204
- tmp_va = vpu_mapping_dm_addr(inst->vpu_inst.dev,
205
- wb[i].vpua);
195
+ handler = inst->vpu_inst.ctx->dev->fw_handler;
196
+ tmp_va = mtk_vcodec_fw_map_dm_addr(handler,
197
+ wb[i].vpua);
206198 memcpy(inst->work_bufs[i].va, tmp_va, wb[i].size);
207199 }
208200 wb[i].iova = inst->work_bufs[i].dma_addr;
....@@ -310,7 +302,8 @@
310302
311303 mtk_vcodec_debug(inst, "->frm_cnt=%d", inst->frm_cnt);
312304
313
- ret = vpu_enc_encode(&inst->vpu_inst, 0, frm_buf, bs_buf, bs_size);
305
+ ret = vpu_enc_encode(&inst->vpu_inst, 0, frm_buf, bs_buf, bs_size,
306
+ NULL);
314307 if (ret)
315308 return ret;
316309
....@@ -332,7 +325,7 @@
332325 return ret;
333326 }
334327
335
-static int vp8_enc_init(struct mtk_vcodec_ctx *ctx, unsigned long *handle)
328
+static int vp8_enc_init(struct mtk_vcodec_ctx *ctx)
336329 {
337330 int ret = 0;
338331 struct venc_vp8_inst *inst;
....@@ -343,7 +336,6 @@
343336
344337 inst->ctx = ctx;
345338 inst->vpu_inst.ctx = ctx;
346
- inst->vpu_inst.dev = ctx->dev->vpu_plat_dev;
347339 inst->vpu_inst.id = IPI_VENC_VP8;
348340 inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx, VENC_LT_SYS);
349341
....@@ -358,12 +350,12 @@
358350 if (ret)
359351 kfree(inst);
360352 else
361
- (*handle) = (unsigned long)inst;
353
+ ctx->drv_handle = inst;
362354
363355 return ret;
364356 }
365357
366
-static int vp8_enc_encode(unsigned long handle,
358
+static int vp8_enc_encode(void *handle,
367359 enum venc_start_opt opt,
368360 struct venc_frm_buf *frm_buf,
369361 struct mtk_vcodec_mem *bs_buf,
....@@ -400,7 +392,7 @@
400392 return ret;
401393 }
402394
403
-static int vp8_enc_set_param(unsigned long handle,
395
+static int vp8_enc_set_param(void *handle,
404396 enum venc_set_param_type type,
405397 struct venc_enc_param *enc_prm)
406398 {
....@@ -451,7 +443,7 @@
451443 return ret;
452444 }
453445
454
-static int vp8_enc_deinit(unsigned long handle)
446
+static int vp8_enc_deinit(void *handle)
455447 {
456448 int ret = 0;
457449 struct venc_vp8_inst *inst = (struct venc_vp8_inst *)handle;
....@@ -469,16 +461,9 @@
469461 return ret;
470462 }
471463
472
-static const struct venc_common_if venc_vp8_if = {
464
+const struct venc_common_if venc_vp8_if = {
473465 .init = vp8_enc_init,
474466 .encode = vp8_enc_encode,
475467 .set_param = vp8_enc_set_param,
476468 .deinit = vp8_enc_deinit,
477469 };
478
-
479
-const struct venc_common_if *get_vp8_enc_comm_if(void);
480
-
481
-const struct venc_common_if *get_vp8_enc_comm_if(void)
482
-{
483
- return &venc_vp8_if;
484
-}