Skip to content

Commit fa02fcd

Browse files
committed
Merge tag 'media/v5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab: - a rand Kconfig fixup for mtk-vcodec - a fix at h264 handling at cedrus codec driver - some warning fixes when config PM is not enabled at marvell-ccic - two fixes at venus codec driver: one related to codec profile and the other one related to a bad error path which causes an OOPS on module re-bind * tag 'media/v5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: media: venus: pm_helpers: Fix kernel module reload media: venus: venc: Fix setting of profile and level media: cedrus: h264: Fix check for presence of scaling matrix media: media/platform/marvell-ccic: fix warnings when CONFIG_PM is not enabled media: mtk-vcodec: fix build breakage when one of VPU or SCP is enabled media: mtk-vcodec: move firmware implementations into their own files
2 parents 127c501 + 9215f6b commit fa02fcd

File tree

15 files changed

+338
-188
lines changed

15 files changed

+338
-188
lines changed

drivers/media/platform/Kconfig

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,31 @@ config VIDEO_MEDIATEK_VCODEC
253253
depends on MTK_IOMMU || COMPILE_TEST
254254
depends on VIDEO_DEV && VIDEO_V4L2
255255
depends on ARCH_MEDIATEK || COMPILE_TEST
256+
depends on VIDEO_MEDIATEK_VPU || MTK_SCP
257+
# The two following lines ensure we have the same state ("m" or "y") as
258+
# our dependencies, to avoid missing symbols during link.
259+
depends on VIDEO_MEDIATEK_VPU || !VIDEO_MEDIATEK_VPU
260+
depends on MTK_SCP || !MTK_SCP
256261
select VIDEOBUF2_DMA_CONTIG
257262
select V4L2_MEM2MEM_DEV
258-
select VIDEO_MEDIATEK_VPU
259-
select MTK_SCP
263+
select VIDEO_MEDIATEK_VCODEC_VPU if VIDEO_MEDIATEK_VPU
264+
select VIDEO_MEDIATEK_VCODEC_SCP if MTK_SCP
260265
help
261-
Mediatek video codec driver provides HW capability to
262-
encode and decode in a range of video formats
263-
This driver rely on VPU driver to communicate with VPU.
266+
Mediatek video codec driver provides HW capability to
267+
encode and decode in a range of video formats on MT8173
268+
and MT8183.
269+
270+
Note that support for MT8173 requires VIDEO_MEDIATEK_VPU to
271+
also be selected. Support for MT8183 depends on MTK_SCP.
272+
273+
To compile this driver as modules, choose M here: the
274+
modules will be called mtk-vcodec-dec and mtk-vcodec-enc.
275+
276+
config VIDEO_MEDIATEK_VCODEC_VPU
277+
bool
264278

265-
To compile this driver as modules, choose M here: the
266-
modules will be called mtk-vcodec-dec and mtk-vcodec-enc.
279+
config VIDEO_MEDIATEK_VCODEC_SCP
280+
bool
267281

268282
config VIDEO_MEM2MEM_DEINTERLACE
269283
tristate "Deinterlace support"

drivers/media/platform/marvell-ccic/mmp-driver.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ static int mmpcam_platform_remove(struct platform_device *pdev)
307307
* Suspend/resume support.
308308
*/
309309

310+
#ifdef CONFIG_PM
310311
static int mmpcam_runtime_resume(struct device *dev)
311312
{
312313
struct mmp_camera *cam = dev_get_drvdata(dev);
@@ -352,6 +353,7 @@ static int __maybe_unused mmpcam_resume(struct device *dev)
352353
return mccic_resume(&cam->mcam);
353354
return 0;
354355
}
356+
#endif
355357

356358
static const struct dev_pm_ops mmpcam_pm_ops = {
357359
SET_RUNTIME_PM_OPS(mmpcam_runtime_suspend, mmpcam_runtime_resume, NULL)

drivers/media/platform/mtk-vcodec/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@ mtk-vcodec-enc-y := venc/venc_vp8_if.o \
2424

2525
mtk-vcodec-common-y := mtk_vcodec_intr.o \
2626
mtk_vcodec_util.o \
27-
mtk_vcodec_fw.o
27+
mtk_vcodec_fw.o \
28+
29+
ifneq ($(CONFIG_VIDEO_MEDIATEK_VCODEC_VPU),)
30+
mtk-vcodec-common-y += mtk_vcodec_fw_vpu.o
31+
endif
32+
33+
ifneq ($(CONFIG_VIDEO_MEDIATEK_VCODEC_SCP),)
34+
mtk-vcodec-common-y += mtk_vcodec_fw_scp.o
35+
endif

drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
241241
}
242242
dma_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
243243

244-
dev->fw_handler = mtk_vcodec_fw_select(dev, fw_type, VPU_RST_DEC);
244+
dev->fw_handler = mtk_vcodec_fw_select(dev, fw_type, DECODER);
245245
if (IS_ERR(dev->fw_handler))
246246
return PTR_ERR(dev->fw_handler);
247247

drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
293293
}
294294
dma_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
295295

296-
dev->fw_handler = mtk_vcodec_fw_select(dev, fw_type, VPU_RST_ENC);
296+
dev->fw_handler = mtk_vcodec_fw_select(dev, fw_type, ENCODER);
297297
if (IS_ERR(dev->fw_handler))
298298
return PTR_ERR(dev->fw_handler);
299299

drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c

Lines changed: 5 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -1,193 +1,29 @@
11
// SPDX-License-Identifier: GPL-2.0
22

33
#include "mtk_vcodec_fw.h"
4+
#include "mtk_vcodec_fw_priv.h"
45
#include "mtk_vcodec_util.h"
56
#include "mtk_vcodec_drv.h"
67

7-
struct mtk_vcodec_fw_ops {
8-
int (*load_firmware)(struct mtk_vcodec_fw *fw);
9-
unsigned int (*get_vdec_capa)(struct mtk_vcodec_fw *fw);
10-
unsigned int (*get_venc_capa)(struct mtk_vcodec_fw *fw);
11-
void * (*map_dm_addr)(struct mtk_vcodec_fw *fw, u32 dtcm_dmem_addr);
12-
int (*ipi_register)(struct mtk_vcodec_fw *fw, int id,
13-
mtk_vcodec_ipi_handler handler, const char *name, void *priv);
14-
int (*ipi_send)(struct mtk_vcodec_fw *fw, int id, void *buf,
15-
unsigned int len, unsigned int wait);
16-
};
17-
18-
struct mtk_vcodec_fw {
19-
enum mtk_vcodec_fw_type type;
20-
const struct mtk_vcodec_fw_ops *ops;
21-
struct platform_device *pdev;
22-
struct mtk_scp *scp;
23-
};
24-
25-
static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw)
26-
{
27-
return vpu_load_firmware(fw->pdev);
28-
}
29-
30-
static unsigned int mtk_vcodec_vpu_get_vdec_capa(struct mtk_vcodec_fw *fw)
31-
{
32-
return vpu_get_vdec_hw_capa(fw->pdev);
33-
}
34-
35-
static unsigned int mtk_vcodec_vpu_get_venc_capa(struct mtk_vcodec_fw *fw)
36-
{
37-
return vpu_get_venc_hw_capa(fw->pdev);
38-
}
39-
40-
static void *mtk_vcodec_vpu_map_dm_addr(struct mtk_vcodec_fw *fw,
41-
u32 dtcm_dmem_addr)
42-
{
43-
return vpu_mapping_dm_addr(fw->pdev, dtcm_dmem_addr);
44-
}
45-
46-
static int mtk_vcodec_vpu_set_ipi_register(struct mtk_vcodec_fw *fw, int id,
47-
mtk_vcodec_ipi_handler handler,
48-
const char *name, void *priv)
49-
{
50-
/*
51-
* The handler we receive takes a void * as its first argument. We
52-
* cannot change this because it needs to be passed down to the rproc
53-
* subsystem when SCP is used. VPU takes a const argument, which is
54-
* more constrained, so the conversion below is safe.
55-
*/
56-
ipi_handler_t handler_const = (ipi_handler_t)handler;
57-
58-
return vpu_ipi_register(fw->pdev, id, handler_const, name, priv);
59-
}
60-
61-
static int mtk_vcodec_vpu_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf,
62-
unsigned int len, unsigned int wait)
63-
{
64-
return vpu_ipi_send(fw->pdev, id, buf, len);
65-
}
66-
67-
static const struct mtk_vcodec_fw_ops mtk_vcodec_vpu_msg = {
68-
.load_firmware = mtk_vcodec_vpu_load_firmware,
69-
.get_vdec_capa = mtk_vcodec_vpu_get_vdec_capa,
70-
.get_venc_capa = mtk_vcodec_vpu_get_venc_capa,
71-
.map_dm_addr = mtk_vcodec_vpu_map_dm_addr,
72-
.ipi_register = mtk_vcodec_vpu_set_ipi_register,
73-
.ipi_send = mtk_vcodec_vpu_ipi_send,
74-
};
75-
76-
static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw)
77-
{
78-
return rproc_boot(scp_get_rproc(fw->scp));
79-
}
80-
81-
static unsigned int mtk_vcodec_scp_get_vdec_capa(struct mtk_vcodec_fw *fw)
82-
{
83-
return scp_get_vdec_hw_capa(fw->scp);
84-
}
85-
86-
static unsigned int mtk_vcodec_scp_get_venc_capa(struct mtk_vcodec_fw *fw)
87-
{
88-
return scp_get_venc_hw_capa(fw->scp);
89-
}
90-
91-
static void *mtk_vcodec_vpu_scp_dm_addr(struct mtk_vcodec_fw *fw,
92-
u32 dtcm_dmem_addr)
93-
{
94-
return scp_mapping_dm_addr(fw->scp, dtcm_dmem_addr);
95-
}
96-
97-
static int mtk_vcodec_scp_set_ipi_register(struct mtk_vcodec_fw *fw, int id,
98-
mtk_vcodec_ipi_handler handler,
99-
const char *name, void *priv)
100-
{
101-
return scp_ipi_register(fw->scp, id, handler, priv);
102-
}
103-
104-
static int mtk_vcodec_scp_ipi_send(struct mtk_vcodec_fw *fw, int id, void *buf,
105-
unsigned int len, unsigned int wait)
106-
{
107-
return scp_ipi_send(fw->scp, id, buf, len, wait);
108-
}
109-
110-
static const struct mtk_vcodec_fw_ops mtk_vcodec_rproc_msg = {
111-
.load_firmware = mtk_vcodec_scp_load_firmware,
112-
.get_vdec_capa = mtk_vcodec_scp_get_vdec_capa,
113-
.get_venc_capa = mtk_vcodec_scp_get_venc_capa,
114-
.map_dm_addr = mtk_vcodec_vpu_scp_dm_addr,
115-
.ipi_register = mtk_vcodec_scp_set_ipi_register,
116-
.ipi_send = mtk_vcodec_scp_ipi_send,
117-
};
118-
119-
static void mtk_vcodec_reset_handler(void *priv)
120-
{
121-
struct mtk_vcodec_dev *dev = priv;
122-
struct mtk_vcodec_ctx *ctx;
123-
124-
mtk_v4l2_err("Watchdog timeout!!");
125-
126-
mutex_lock(&dev->dev_mutex);
127-
list_for_each_entry(ctx, &dev->ctx_list, list) {
128-
ctx->state = MTK_STATE_ABORT;
129-
mtk_v4l2_debug(0, "[%d] Change to state MTK_STATE_ABORT",
130-
ctx->id);
131-
}
132-
mutex_unlock(&dev->dev_mutex);
133-
}
134-
1358
struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev,
1369
enum mtk_vcodec_fw_type type,
137-
enum rst_id rst_id)
10+
enum mtk_vcodec_fw_use fw_use)
13811
{
139-
const struct mtk_vcodec_fw_ops *ops;
140-
struct mtk_vcodec_fw *fw;
141-
struct platform_device *fw_pdev = NULL;
142-
struct mtk_scp *scp = NULL;
143-
14412
switch (type) {
14513
case VPU:
146-
ops = &mtk_vcodec_vpu_msg;
147-
fw_pdev = vpu_get_plat_device(dev->plat_dev);
148-
if (!fw_pdev) {
149-
mtk_v4l2_err("firmware device is not ready");
150-
return ERR_PTR(-EINVAL);
151-
}
152-
vpu_wdt_reg_handler(fw_pdev, mtk_vcodec_reset_handler,
153-
dev, rst_id);
154-
break;
14+
return mtk_vcodec_fw_vpu_init(dev, fw_use);
15515
case SCP:
156-
ops = &mtk_vcodec_rproc_msg;
157-
scp = scp_get(dev->plat_dev);
158-
if (!scp) {
159-
mtk_v4l2_err("could not get vdec scp handle");
160-
return ERR_PTR(-EPROBE_DEFER);
161-
}
162-
break;
16+
return mtk_vcodec_fw_scp_init(dev);
16317
default:
16418
mtk_v4l2_err("invalid vcodec fw type");
16519
return ERR_PTR(-EINVAL);
16620
}
167-
168-
fw = devm_kzalloc(&dev->plat_dev->dev, sizeof(*fw), GFP_KERNEL);
169-
if (!fw)
170-
return ERR_PTR(-EINVAL);
171-
172-
fw->type = type;
173-
fw->ops = ops;
174-
fw->pdev = fw_pdev;
175-
fw->scp = scp;
176-
177-
return fw;
17821
}
17922
EXPORT_SYMBOL_GPL(mtk_vcodec_fw_select);
18023

18124
void mtk_vcodec_fw_release(struct mtk_vcodec_fw *fw)
18225
{
183-
switch (fw->type) {
184-
case VPU:
185-
put_device(&fw->pdev->dev);
186-
break;
187-
case SCP:
188-
scp_put(fw->scp);
189-
break;
190-
}
26+
fw->ops->release(fw);
19127
}
19228
EXPORT_SYMBOL_GPL(mtk_vcodec_fw_release);
19329

drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ enum mtk_vcodec_fw_type {
1515
SCP,
1616
};
1717

18+
enum mtk_vcodec_fw_use {
19+
DECODER,
20+
ENCODER,
21+
};
22+
1823
struct mtk_vcodec_fw;
1924

2025
typedef void (*mtk_vcodec_ipi_handler) (void *data,
2126
unsigned int len, void *priv);
2227

2328
struct mtk_vcodec_fw *mtk_vcodec_fw_select(struct mtk_vcodec_dev *dev,
2429
enum mtk_vcodec_fw_type type,
25-
enum rst_id rst_id);
30+
enum mtk_vcodec_fw_use fw_use);
2631
void mtk_vcodec_fw_release(struct mtk_vcodec_fw *fw);
2732

2833
int mtk_vcodec_fw_load_firmware(struct mtk_vcodec_fw *fw);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef _MTK_VCODEC_FW_PRIV_H_
4+
#define _MTK_VCODEC_FW_PRIV_H_
5+
6+
#include "mtk_vcodec_fw.h"
7+
8+
struct mtk_vcodec_dev;
9+
10+
struct mtk_vcodec_fw {
11+
enum mtk_vcodec_fw_type type;
12+
const struct mtk_vcodec_fw_ops *ops;
13+
struct platform_device *pdev;
14+
struct mtk_scp *scp;
15+
};
16+
17+
struct mtk_vcodec_fw_ops {
18+
int (*load_firmware)(struct mtk_vcodec_fw *fw);
19+
unsigned int (*get_vdec_capa)(struct mtk_vcodec_fw *fw);
20+
unsigned int (*get_venc_capa)(struct mtk_vcodec_fw *fw);
21+
void *(*map_dm_addr)(struct mtk_vcodec_fw *fw, u32 dtcm_dmem_addr);
22+
int (*ipi_register)(struct mtk_vcodec_fw *fw, int id,
23+
mtk_vcodec_ipi_handler handler, const char *name,
24+
void *priv);
25+
int (*ipi_send)(struct mtk_vcodec_fw *fw, int id, void *buf,
26+
unsigned int len, unsigned int wait);
27+
void (*release)(struct mtk_vcodec_fw *fw);
28+
};
29+
30+
#if IS_ENABLED(CONFIG_VIDEO_MEDIATEK_VCODEC_VPU)
31+
struct mtk_vcodec_fw *mtk_vcodec_fw_vpu_init(struct mtk_vcodec_dev *dev,
32+
enum mtk_vcodec_fw_use fw_use);
33+
#else
34+
static inline struct mtk_vcodec_fw *
35+
mtk_vcodec_fw_vpu_init(struct mtk_vcodec_dev *dev,
36+
enum mtk_vcodec_fw_use fw_use)
37+
{
38+
return ERR_PTR(-ENODEV);
39+
}
40+
#endif /* CONFIG_VIDEO_MEDIATEK_VCODEC_VPU */
41+
42+
#if IS_ENABLED(CONFIG_VIDEO_MEDIATEK_VCODEC_SCP)
43+
struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(struct mtk_vcodec_dev *dev);
44+
#else
45+
static inline struct mtk_vcodec_fw *
46+
mtk_vcodec_fw_scp_init(struct mtk_vcodec_dev *dev)
47+
{
48+
return ERR_PTR(-ENODEV);
49+
}
50+
#endif /* CONFIG_VIDEO_MEDIATEK_VCODEC_SCP */
51+
52+
#endif /* _MTK_VCODEC_FW_PRIV_H_ */

0 commit comments

Comments
 (0)