From: Maxime Ripard Date: Mon, 24 Oct 2022 11:24:03 +0000 (+0200) Subject: rpivid: Convert to new clock rate API X-Git-Tag: accepted/tizen/unified/20230118.172025~293 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c6045999c185c3d9bc3e2132fce24f6ec411b66;p=platform%2Fkernel%2Flinux-rpi.git rpivid: Convert to new clock rate API Signed-off-by: Maxime Ripard --- diff --git a/drivers/staging/media/rpivid/rpivid.h b/drivers/staging/media/rpivid/rpivid.h index dbe496a..9d6c2ad 100644 --- a/drivers/staging/media/rpivid/rpivid.h +++ b/drivers/staging/media/rpivid/rpivid.h @@ -185,6 +185,7 @@ struct rpivid_dev { void __iomem *base_h265; struct clk *clock; + unsigned long max_clock_rate; int cache_align; diff --git a/drivers/staging/media/rpivid/rpivid_hw.c b/drivers/staging/media/rpivid/rpivid_hw.c index e7d1793..1026fa6 100644 --- a/drivers/staging/media/rpivid/rpivid_hw.c +++ b/drivers/staging/media/rpivid/rpivid_hw.c @@ -25,6 +25,8 @@ #include #include +#include + #include "rpivid.h" #include "rpivid_hw.h" @@ -303,6 +305,8 @@ void rpivid_hw_irq_active2_irq(struct rpivid_dev *dev, int rpivid_hw_probe(struct rpivid_dev *dev) { + struct rpi_firmware *firmware; + struct device_node *node; struct resource *res; __u32 irq_stat; int irq_dec; @@ -331,6 +335,19 @@ int rpivid_hw_probe(struct rpivid_dev *dev) if (IS_ERR(dev->clock)) return PTR_ERR(dev->clock); + node = rpi_firmware_find_node(); + if (!node) + return -EINVAL; + + firmware = rpi_firmware_get(node); + of_node_put(node); + if (!firmware) + return -EPROBE_DEFER; + + dev->max_clock_rate = rpi_firmware_clk_get_max_rate(firmware, + RPI_FIRMWARE_HEVC_CLK_ID); + rpi_firmware_put(firmware); + dev->cache_align = dma_get_cache_alignment(); // Disable IRQs & reset anything pending diff --git a/drivers/staging/media/rpivid/rpivid_video.c b/drivers/staging/media/rpivid/rpivid_video.c index bab3ed3..37144a6 100644 --- a/drivers/staging/media/rpivid/rpivid_video.c +++ b/drivers/staging/media/rpivid/rpivid_video.c @@ -555,12 +555,9 @@ static void stop_clock(struct rpivid_dev *dev, struct rpivid_ctx *ctx) /* Always starts the clock if it isn't already on this ctx */ static int start_clock(struct rpivid_dev *dev, struct rpivid_ctx *ctx) { - long max_hevc_clock; int rv; - max_hevc_clock = clk_get_max_rate(dev->clock); - - rv = clk_set_min_rate(dev->clock, max_hevc_clock); + rv = clk_set_min_rate(dev->clock, dev->max_clock_rate); if (rv) { dev_err(dev->dev, "Failed to set clock rate\n"); return rv;