bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0372-rpivid-Request-maximum-hevc-clock.patch
1 From 276aead8fe8654ba130f2bc866fd8aa7f236e507 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Mon, 22 Feb 2021 18:50:50 +0000
4 Subject: [PATCH] rpivid: Request maximum hevc clock
5
6 Query maximum and minimum clock from driver
7 and use those
8
9 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
10 ---
11 drivers/staging/media/rpivid/rpivid_video.c | 9 ++++++++-
12 1 file changed, 8 insertions(+), 1 deletion(-)
13
14 --- a/drivers/staging/media/rpivid/rpivid_video.c
15 +++ b/drivers/staging/media/rpivid/rpivid_video.c
16 @@ -490,6 +490,7 @@ static int rpivid_start_streaming(struct
17 {
18 struct rpivid_ctx *ctx = vb2_get_drv_priv(vq);
19 struct rpivid_dev *dev = ctx->dev;
20 + long max_hevc_clock = clk_round_rate(dev->clock, ULONG_MAX);
21 int ret = 0;
22
23 if (ctx->src_fmt.pixelformat != V4L2_PIX_FMT_HEVC_SLICE)
24 @@ -498,7 +499,7 @@ static int rpivid_start_streaming(struct
25 if (V4L2_TYPE_IS_OUTPUT(vq->type) && dev->dec_ops->start)
26 ret = dev->dec_ops->start(ctx);
27
28 - ret = clk_set_rate(dev->clock, 500 * 1000 * 1000);
29 + ret = clk_set_rate(dev->clock, max_hevc_clock);
30 if (ret) {
31 dev_err(dev->dev, "Failed to set clock rate\n");
32 goto out;
33 @@ -519,12 +520,18 @@ static void rpivid_stop_streaming(struct
34 {
35 struct rpivid_ctx *ctx = vb2_get_drv_priv(vq);
36 struct rpivid_dev *dev = ctx->dev;
37 + long min_hevc_clock = clk_round_rate(dev->clock, 0);
38 + int ret;
39
40 if (V4L2_TYPE_IS_OUTPUT(vq->type) && dev->dec_ops->stop)
41 dev->dec_ops->stop(ctx);
42
43 rpivid_queue_cleanup(vq, VB2_BUF_STATE_ERROR);
44
45 + ret = clk_set_rate(dev->clock, min_hevc_clock);
46 + if (ret)
47 + dev_err(dev->dev, "Failed to set minimum clock rate\n");
48 +
49 clk_disable_unprepare(dev->clock);
50 }
51