Skip to contentSkip to conversation

media: staging: imgu: make imgu work on low frequency for low input

PATCH In review [email protected] 2 participants 2 messages Aug 16, 2019 – Aug 19, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: staging: imgu: make imgu work on low frequency for low input

From: Bingbu Cao <[email protected]>

Currently, imgu is working on 450MHz for all cases, however in some cases (input frame less than 2048x1152), the imgu did not need work in high frequency.
This patch make imgu work on 200MHz if the imgu input frame is less than 2048x1152 to save power.

---
 drivers/staging/media/ipu3/ipu3-css.c |  6 +++---
 drivers/staging/media/ipu3/ipu3-css.h |  3 ++-
 drivers/staging/media/ipu3/ipu3.c     | 16 ++++++++++++++--
 3 files changed, 19 insertions(+), 6 deletions(-)
drivers/staging/media/ipu3/ipu3-css.c +3 -3
index fd1ed84c400c..a0002ccadbfc 100644
@@ -210,12 +210,12 @@ static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp)
 
 /* Initialize the IPU3 CSS hardware and associated h/w blocks */
 
-int imgu_css_set_powerup(struct device *dev, void __iomem *base)
+int imgu_css_set_powerup(struct device *dev, void __iomem *base,
+			 unsigned int freq)
 {
-	static const unsigned int freq = 450;
 	u32 pm_ctrl, state, val;
 
-	dev_dbg(dev, "%s\n", __func__);
+	dev_dbg(dev, "%s with freq %u\n", __func__, freq);
 	/* Clear the CSS busy signal */
 	readl(base + IMGU_REG_GP_BUSY);
 	writel(0, base + IMGU_REG_GP_BUSY);
drivers/staging/media/ipu3/ipu3-css.h +2 -1
index 6b8bab27ab1f..6108a068b228 100644
@@ -187,7 +187,8 @@ bool imgu_css_is_streaming(struct imgu_css *css);
 bool imgu_css_pipe_queue_empty(struct imgu_css *css, unsigned int pipe);
 
 /******************* css hw *******************/
-int imgu_css_set_powerup(struct device *dev, void __iomem *base);
+int imgu_css_set_powerup(struct device *dev, void __iomem *base,
+			 unsigned int freq);
 void imgu_css_set_powerdown(struct device *dev, void __iomem *base);
 int imgu_css_irq_ack(struct imgu_css *css);
 
drivers/staging/media/ipu3/ipu3.c +14 -2
index 06a61f31ca50..4d53aad31483 100644
@@ -345,8 +345,20 @@ int imgu_queue_buffers(struct imgu_device *imgu, bool initial, unsigned int pipe
 static int imgu_powerup(struct imgu_device *imgu)
 {
 	int r;
+	unsigned int pipe;
+	unsigned int freq = 200;
+	struct v4l2_mbus_framefmt *fmt;
+
+	/* input larger than 2048*1152, ask imgu to work on high freq */
+	for_each_set_bit(pipe, imgu->css.enabled_pipes, IMGU_MAX_PIPE_NUM) {
+		fmt = &imgu->imgu_pipe[pipe].nodes[IMGU_NODE_IN].pad_fmt;
+		dev_dbg(&imgu->pci_dev->dev, "pipe %u input format = %ux%u",
+			pipe, fmt->width, fmt->height);
+		if ((fmt->width * fmt->height) >= (2048 * 1152))
+			freq = 450;
+	}
 
-	r = imgu_css_set_powerup(&imgu->pci_dev->dev, imgu->base);
+	r = imgu_css_set_powerup(&imgu->pci_dev->dev, imgu->base, freq);
 	if (r)
 		return r;
 
@@ -666,7 +678,7 @@ static int imgu_pci_probe(struct pci_dev *pci_dev,
 	atomic_set(&imgu->qbuf_barrier, 0);
 	init_waitqueue_head(&imgu->buf_drain_wq);
 
-	r = imgu_css_set_powerup(&pci_dev->dev, imgu->base);
+	r = imgu_css_set_powerup(&pci_dev->dev, imgu->base, 200);
 	if (r) {
 		dev_err(&pci_dev->dev,
 			"failed to power up CSS (%d)\n", r);
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#1 lore raw

Hi Bingbu,

Quoted 86 lines · On Fri, Aug 16, 2019 at 7:12 PM <[email protected]> wrote:

From: Bingbu Cao <[email protected]>

Currently, imgu is working on 450MHz for all cases, however in some cases (input frame less than 2048x1152), the imgu did not need work in high frequency.
This patch make imgu work on 200MHz if the imgu input frame is less than 2048x1152 to save power.

---
 drivers/staging/media/ipu3/ipu3-css.c |  6 +++---
 drivers/staging/media/ipu3/ipu3-css.h |  3 ++-
 drivers/staging/media/ipu3/ipu3.c     | 16 ++++++++++++++--
 3 files changed, 19 insertions(+), 6 deletions(-)
drivers/staging/media/ipu3/ipu3-css.c +3 -3
index fd1ed84c400c..a0002ccadbfc 100644
@@ -210,12 +210,12 @@ static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp)
 
 /* Initialize the IPU3 CSS hardware and associated h/w blocks */
 
-int imgu_css_set_powerup(struct device *dev, void __iomem *base)
+int imgu_css_set_powerup(struct device *dev, void __iomem *base,
+                        unsigned int freq)
 {
-       static const unsigned int freq = 450;
        u32 pm_ctrl, state, val;
 
-       dev_dbg(dev, "%s\n", __func__);
+       dev_dbg(dev, "%s with freq %u\n", __func__, freq);
        /* Clear the CSS busy signal */
        readl(base + IMGU_REG_GP_BUSY);
        writel(0, base + IMGU_REG_GP_BUSY);
drivers/staging/media/ipu3/ipu3-css.h +2 -1
index 6b8bab27ab1f..6108a068b228 100644
@@ -187,7 +187,8 @@ bool imgu_css_is_streaming(struct imgu_css *css);
 bool imgu_css_pipe_queue_empty(struct imgu_css *css, unsigned int pipe);
 
 /******************* css hw *******************/
-int imgu_css_set_powerup(struct device *dev, void __iomem *base);
+int imgu_css_set_powerup(struct device *dev, void __iomem *base,
+                        unsigned int freq);
 void imgu_css_set_powerdown(struct device *dev, void __iomem *base);
 int imgu_css_irq_ack(struct imgu_css *css);
 
drivers/staging/media/ipu3/ipu3.c +14 -3
index 06a61f31ca50..4d53aad31483 100644
@@ -345,8 +345,20 @@ int imgu_queue_buffers(struct imgu_device *imgu, bool initial, unsigned int pipe
 static int imgu_powerup(struct imgu_device *imgu)
 {
        int r;
+       unsigned int pipe;
+       unsigned int freq = 200;
+       struct v4l2_mbus_framefmt *fmt;
+
+       /* input larger than 2048*1152, ask imgu to work on high freq */
+       for_each_set_bit(pipe, imgu->css.enabled_pipes, IMGU_MAX_PIPE_NUM) {
+               fmt = &imgu->imgu_pipe[pipe].nodes[IMGU_NODE_IN].pad_fmt;
+               dev_dbg(&imgu->pci_dev->dev, "pipe %u input format = %ux%u",
+                       pipe, fmt->width, fmt->height);
+               if ((fmt->width * fmt->height) >= (2048 * 1152))
+                       freq = 450;
+       }
 
-       r = imgu_css_set_powerup(&imgu->pci_dev->dev, imgu->base);
+       r = imgu_css_set_powerup(&imgu->pci_dev->dev, imgu->base, freq);
        if (r)
                return r;
 
@@ -666,7 +678,7 @@ static int imgu_pci_probe(struct pci_dev *pci_dev,
        atomic_set(&imgu->qbuf_barrier, 0);
        init_waitqueue_head(&imgu->buf_drain_wq);
 
-       r = imgu_css_set_powerup(&pci_dev->dev, imgu->base);
+       r = imgu_css_set_powerup(&pci_dev->dev, imgu->base, 200);
        if (r) {
                dev_err(&pci_dev->dev,
                        "failed to power up CSS (%d)\n", r);
--
Quoted 2 lines

2.7.4

Thanks for addressing my comments.

Best regards,
Tomasz