Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
718d713
media/hevc_d: Fix off by one worst size cmd buffer checks
jc-kynesim Nov 17, 2026
1ea622e
media/hevc_d: Avoid unlikely race between decode & streamoff
jc-kynesim Nov 17, 2026
7856527
media/hevc_d: Fix setup order so error path is always valid
jc-kynesim Nov 17, 2026
8871699
media/hevc_d: Fix PPS/SPS typo in comment
jc-kynesim Nov 19, 2026
6eeaa83
media/hevc_d: Only start decode h/w after both CAPTURE and OUTPUT hav…
jc-kynesim Nov 19, 2026
b4494d8
media/hevc_d: Remove dev_mutex and replace usage with ctx_mutex
jc-kynesim Nov 19, 2026
1160b3e
media/hevc_d: Ensure that a removed buffer is not in use
jc-kynesim Nov 19, 2026
4d8517a
media/hevc_d: Remove min_queued_buffers = 1 from CAPTURE queue
jc-kynesim Nov 19, 2026
9a58cc5
media/hevc_d: Ensure media requests are cleaned up correctly
jc-kynesim Nov 19, 2026
ca34115
media/hevc_d: Lock controls against change in phase 0
jc-kynesim Nov 19, 2026
4395b19
media/hevc_d: Fix up hevc_d_open error handling
jc-kynesim Nov 19, 2026
63bd036
media/hevc_d: Tighten up SPS/PPS/SH value checking
jc-kynesim Nov 19, 2026
7034510
media/hevc_d: Ensure tiles are given in order
jc-kynesim Nov 19, 2026
529b6e3
media/hevc_d: Prevent dst format change whilst streaming
jc-kynesim Nov 20, 2026
8a3dddb
media/hevc_d: Use vb2_plane_size when checking plane sizes
jc-kynesim Nov 20, 2026
eb4e21b
media/hevc_d: Fix behaviour if unbound whilst running
jc-kynesim Nov 20, 2026
9255d04
media/hevc_d: try_fmt_vid_cap uses fmt from SPS if unmatched
jc-kynesim Nov 20, 2026
253fe73
media/hevc_d: Change warning messages to debug for control misconfigu…
jc-kynesim Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 44 additions & 17 deletions drivers/media/platform/raspberrypi/hevc_dec/hevc_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static int hevc_d_init_ctrls(struct hevc_d_dev *dev, struct hevc_d_ctx *ctx)
{
struct v4l2_ctrl_handler *hdl = &ctx->hdl;
unsigned int i;
int ret;

v4l2_ctrl_handler_init(hdl, ARRAY_SIZE(hevc_d_ctrls));
if (hdl->error) {
Expand All @@ -111,8 +112,14 @@ static int hevc_d_init_ctrls(struct hevc_d_dev *dev, struct hevc_d_ctx *ctx)
}
}

ret = v4l2_ctrl_handler_setup(hdl);
if (ret) {
v4l2_err(&dev->v4l2_dev, "Failed to set up control handler\n");
v4l2_ctrl_handler_free(hdl);
return ret;
}

ctx->fh.ctrl_handler = hdl;
v4l2_ctrl_handler_setup(hdl);

return 0;
}
Expand Down Expand Up @@ -155,6 +162,7 @@ static int hevc_d_open(struct file *file)
err_ctx:
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
err_free:
v4l2_fh_exit(&ctx->fh);
mutex_destroy(&ctx->ctx_mutex);
kfree(ctx);
return ret;
Expand Down Expand Up @@ -190,13 +198,39 @@ static const struct v4l2_file_operations hevc_d_fops = {
.mmap = v4l2_m2m_fop_mmap,
};

/*
* Separate device release from unregister as unbind doesn't shut everything
* down. On unbind this may happen some time after unregister.
*/
static void hevc_d_video_device_release(struct video_device *vfd)
{
struct hevc_d_dev *dev = container_of(vfd, struct hevc_d_dev, vfd);

v4l2_device_unregister(&dev->v4l2_dev);
v4l2_m2m_release(dev->m2m_dev);
media_device_cleanup(&dev->mdev);
kfree(dev);
}

static void hevc_d_unregister(struct hevc_d_dev *dev)
{
/* Stop new jobs being started - never resumed */
v4l2_m2m_suspend(dev->m2m_dev);
/* Wait for any work still in flight */
hevc_d_h265_sync(dev);
/* H/w now idle so we can shut it down */
hevc_d_hw_remove(dev);
/* Must be last - drops what may be the final ref to dev */
video_unregister_device(&dev->vfd);
}

static const struct video_device hevc_d_video_device = {
.name = HEVC_D_NAME,
.vfl_dir = VFL_DIR_M2M,
.fops = &hevc_d_fops,
.ioctl_ops = &hevc_d_ioctl_ops,
.minor = -1,
.release = video_device_release_empty,
.release = hevc_d_video_device_release,
.device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING,
};

Expand All @@ -215,7 +249,7 @@ static int hevc_d_probe(struct platform_device *pdev)
struct video_device *vfd;
int ret;

dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
dev = kzalloc_obj(*dev);
if (!dev)
return -ENOMEM;

Expand All @@ -227,7 +261,7 @@ static int hevc_d_probe(struct platform_device *pdev)
ret = hevc_d_hw_probe(dev);
if (ret) {
dev_err_probe(&pdev->dev, ret, "Failed to probe hardware\n");
return ret;
goto err_free;
}

ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
Expand All @@ -236,10 +270,7 @@ static int hevc_d_probe(struct platform_device *pdev)
goto err_hw;
}

mutex_init(&dev->dev_mutex);

vfd = &dev->vfd;
vfd->lock = &dev->dev_mutex;
vfd->v4l2_dev = &dev->v4l2_dev;

snprintf(vfd->name, sizeof(vfd->name), "%s", hevc_d_video_device.name);
Expand Down Expand Up @@ -298,15 +329,18 @@ static int hevc_d_probe(struct platform_device *pdev)
err_m2m_mc:
v4l2_m2m_unregister_media_controller(dev->m2m_dev);
err_video:
video_unregister_device(&dev->vfd);
hevc_d_unregister(dev);
return ret;

err_m2m:
media_device_cleanup(&dev->mdev);
v4l2_m2m_release(dev->m2m_dev);
err_v4l2:
mutex_destroy(&dev->dev_mutex);
v4l2_device_unregister(&dev->v4l2_dev);
err_hw:
hevc_d_hw_remove(dev);
err_free:
kfree(dev);

return ret;
}
Expand All @@ -317,14 +351,7 @@ static void hevc_d_remove(struct platform_device *pdev)

media_device_unregister(&dev->mdev);
v4l2_m2m_unregister_media_controller(dev->m2m_dev);
media_device_cleanup(&dev->mdev);

v4l2_m2m_release(dev->m2m_dev);
video_unregister_device(&dev->vfd);
mutex_destroy(&dev->dev_mutex);
v4l2_device_unregister(&dev->v4l2_dev);

hevc_d_hw_remove(dev);
hevc_d_unregister(dev);
}

static int hevc_d_runtime_suspend(struct device *d)
Expand Down
5 changes: 1 addition & 4 deletions drivers/media/platform/raspberrypi/hevc_dec/hevc_d.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct hevc_d_ctx {
*/
int fatal_err;

/* Lock for queue operations */
/* Lock for queue operations and src_fmt / dst_fmt */
struct mutex ctx_mutex;

struct v4l2_ctrl_handler hdl;
Expand Down Expand Up @@ -180,9 +180,6 @@ struct hevc_d_dev {
struct device *dev;
struct v4l2_m2m_dev *m2m_dev;

/* Video device file (vfd) mutex */
struct mutex dev_mutex;

void __iomem *base_irq;
void __iomem *base_h265;

Expand Down
Loading