f7775015e127e36c7578a622a5ebaf226152668d
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.10 / 950-0541-rpivid-Switch-to-new-clock-api.patch
1 From 4ffdf70996826a87fceb78f2399c98e8a4c6aa89 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Mon, 19 Apr 2021 19:30:26 +0100
4 Subject: [PATCH] rpivid: Switch to new clock api
5
6 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
7 ---
8 drivers/staging/media/rpivid/rpivid.h | 1 +
9 drivers/staging/media/rpivid/rpivid_video.c | 11 +++--------
10 2 files changed, 4 insertions(+), 8 deletions(-)
11
12 --- a/drivers/staging/media/rpivid/rpivid.h
13 +++ b/drivers/staging/media/rpivid/rpivid.h
14 @@ -172,6 +172,7 @@ struct rpivid_dev {
15 void __iomem *base_h265;
16
17 struct clk *clock;
18 + struct clk_request *hevc_req;
19
20 struct rpivid_hw_irq_ctrl ic_active1;
21 struct rpivid_hw_irq_ctrl ic_active2;
22 --- a/drivers/staging/media/rpivid/rpivid_video.c
23 +++ b/drivers/staging/media/rpivid/rpivid_video.c
24 @@ -499,8 +499,8 @@ 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, max_hevc_clock);
29 - if (ret) {
30 + dev->hevc_req = clk_request_start(dev->clock, max_hevc_clock);
31 + if (!dev->hevc_req) {
32 dev_err(dev->dev, "Failed to set clock rate\n");
33 goto out;
34 }
35 @@ -520,18 +520,13 @@ static void rpivid_stop_streaming(struct
36 {
37 struct rpivid_ctx *ctx = vb2_get_drv_priv(vq);
38 struct rpivid_dev *dev = ctx->dev;
39 - long min_hevc_clock = clk_round_rate(dev->clock, 0);
40 - int ret;
41
42 if (V4L2_TYPE_IS_OUTPUT(vq->type) && dev->dec_ops->stop)
43 dev->dec_ops->stop(ctx);
44
45 rpivid_queue_cleanup(vq, VB2_BUF_STATE_ERROR);
46
47 - ret = clk_set_rate(dev->clock, min_hevc_clock);
48 - if (ret)
49 - dev_err(dev->dev, "Failed to set minimum clock rate\n");
50 -
51 + clk_request_done(dev->hevc_req);
52 clk_disable_unprepare(dev->clock);
53 }
54