media: staging: imgu: make imgu work on low frequency for low input
Subsystems (3)
PATCH 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 2.3MP), the imgu did not need work in high frequency.
This patch make imgu work on 200MHz if the imgu input frame is less than 2.3MP to save power.
--- drivers/staging/media/ipu3/ipu3-css.c | 7 ++++--- drivers/staging/media/ipu3/ipu3-css.h | 3 ++- drivers/staging/media/ipu3/ipu3-v4l2.c | 6 ++++++ drivers/staging/media/ipu3/ipu3.c | 6 ++++-- drivers/staging/media/ipu3/ipu3.h | 1 + 5 files changed, 17 insertions(+), 6 deletions(-)
drivers/staging/media/ipu3/ipu3-css.c +4 -3
@@ -210,12 +210,13 @@ 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,bool low_power) { -static const unsigned int freq =450 ; +unsigned int freq;u32 pm_ctrl, state, val; -dev_dbg (dev,"%s\n" , __func__); + freq = low_power ?200 :450 ; +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
@@ -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, +bool low_power);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-v4l2.c +6 -0
@@ -182,6 +182,12 @@ static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, fmt->format.height =clamp (fmt->format.height,IPU3_INPUT_MIN_HEIGHT ,IPU3_INPUT_MAX_HEIGHT ); + +/* input less than 2.3MP, ask imgu to work with low freq */ +if ((fmt->format.width * fmt->format.height) < (2048 *1152 )) + imgu->low_power = true; +else + imgu->low_power = false; } *mf = fmt->format;
drivers/staging/media/ipu3/ipu3.c +4 -2
@@ -346,7 +346,8 @@ static int imgu_powerup(struct imgu_device *imgu) {int r; - r =imgu_css_set_powerup (&imgu->pci_dev->dev, imgu->base); + r =imgu_css_set_powerup (&imgu->pci_dev->dev, imgu->base, + imgu->low_power);if (r)return r;
@@ -666,7 +667,8 @@ 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); + imgu->low_power = false; + r =imgu_css_set_powerup (&pci_dev->dev, imgu->base, imgu->low_power);if (r) {dev_err (&pci_dev->dev,"failed to power up CSS (%d)\n" , r);
drivers/staging/media/ipu3/ipu3.h +1 -0
@@ -152,6 +152,7 @@ struct imgu_device {bool suspend_in_stream;/* Used to wait for FW buffer queue drain. */ wait_queue_head_t buf_drain_wq; +bool low_power; };unsigned int imgu_node_to_queue (unsigned int node);
Signature · 1 line
2.7.4
Hi Bingbu,
Quoted 9 lines · On Fri, Aug 16, 2019 at 12:25 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 2.3MP), the imgu did not need work in high frequency.
This patch make imgu work on 200MHz if the imgu input frame is less than 2.3MP to save power.
Thanks for the patch! Please see my comments inline.
Quoted 14 lines
Signed-off-by Bingbu Cao <[email protected]>--- drivers/staging/media/ipu3/ipu3-css.c | 7 ++++--- drivers/staging/media/ipu3/ipu3-css.h | 3 ++- drivers/staging/media/ipu3/ipu3-v4l2.c | 6 ++++++ drivers/staging/media/ipu3/ipu3.c | 6 ++++-- drivers/staging/media/ipu3/ipu3.h | 1 + 5 files changed, 17 insertions(+), 6 deletions(-)drivers/staging/media/ipu3/ipu3-css.c +0
-0
drivers/staging/media/ipu3/ipu3-css.c static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp) · line 215
Quoted 8 lines
drivers/staging/media/ipu3/ipu3-css.c +2
-2@@ -210,12 +210,13 @@ 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,bool low_power) { -static const unsigned int freq =450 ; +unsigned int freq;
How about making freq the argument to this function rather than introducing some artificial boolean?
Quoted 27 lines
drivers/staging/media/ipu3/ipu3-css.c +2
-1u32 pm_ctrl, state, val; -dev_dbg (dev,"%s\n" , __func__); + freq = low_power ?200 :450 ; +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@@ -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, +bool low_power);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-v4l2.c +0
-0
drivers/staging/media/ipu3/ipu3-v4l2.c static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, · line 187
Quoted 6 lines
drivers/staging/media/ipu3/ipu3-v4l2.c +3
-0@@ -182,6 +182,12 @@ static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, fmt->format.height =clamp (fmt->format.height,IPU3_INPUT_MIN_HEIGHT ,IPU3_INPUT_MAX_HEIGHT ); + +/* input less than 2.3MP, ask imgu to work with low freq */ +if ((fmt->format.width * fmt->format.height) < (2048 *1152 ))
Why 2048 * 1152 specifically if we just care about the number of pixels? Also it's slightly more than 2.3Mpix (2.359296 Mpix) making the comment inaccurate.
drivers/staging/media/ipu3/ipu3-v4l2.c static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, · line 190
Quoted 3 lines
drivers/staging/media/ipu3/ipu3-v4l2.c +3
-0+ imgu->low_power = true; + else + imgu->low_power = false;
There should be no need to store this, as we should have access to the exact format when we start streaming. Could you move the check there?
Also, we have 2 pipes. How do they play together?
Best regards,
Tomasz
Hi, Tomasz
Thanks for your review.
Quoted 32 lines · Tomasz Figa
Hi Bingbu,
Quoted 9 lines · On Fri, Aug 16, 2019 at 12:25 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 2.3MP), the imgu did not need work in high frequency.
This patch make imgu work on 200MHz if the imgu input frame is less than 2.3MP to save power.Thanks for the patch! Please see my comments inline.
Quoted 17 lines
Signed-off-by Bingbu Cao <[email protected]>--- drivers/staging/media/ipu3/ipu3-css.c | 7 ++++--- drivers/staging/media/ipu3/ipu3-css.h | 3 ++- drivers/staging/media/ipu3/ipu3-v4l2.c | 6 ++++++ drivers/staging/media/ipu3/ipu3.c | 6 ++++-- drivers/staging/media/ipu3/ipu3.h | 1 + 5 files changed, 17 insertions(+), 6 deletions(-)drivers/staging/media/ipu3/ipu3-css.c +0
-0@@ -210,12 +210,13 @@ static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp)/* Initialize the IPU3 CSS hardware and associated h/w blocks */
Quoted 8 lines
drivers/staging/media/ipu3/ipu3-css.c static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp) · line 215
Quoted 5 lines
drivers/staging/media/ipu3/ipu3-css.c +2
-2-int imgu_css_set_powerup (struct device *dev,void __iomem *base) +int imgu_css_set_powerup (struct device *dev,void __iomem *base,bool low_power) { -static const unsigned int freq =450 ; +unsigned int freq;How about making freq the argument to this function rather than introducing some artificial boolean?
Let me try to move the check into imgu_powerup().
Quoted 23 lines
Quoted 23 lines
drivers/staging/media/ipu3/ipu3-css.c +2
-1u32 pm_ctrl, state, val; -dev_dbg (dev,"%s\n" , __func__); + freq = low_power ?200 :450 ; +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@@ -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, +bool low_power);void imgu_css_set_powerdown (struct device *dev,void __iomem *base);int imgu_css_irq_ack (struct imgu_css *css);
Quoted 15 lines
drivers/staging/media/ipu3/ipu3-v4l2.c static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, · line 187
Quoted 11 lines
drivers/staging/media/ipu3/ipu3-v4l2.c +3
-0@@ -182,6 +182,12 @@ static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, fmt->format.height =clamp (fmt->format.height,IPU3_INPUT_MIN_HEIGHT ,IPU3_INPUT_MAX_HEIGHT ); + +/* input less than 2.3MP, ask imgu to work with low freq */ +if ((fmt->format.width * fmt->format.height) < (2048 *1152 ))Why 2048 * 1152 specifically if we just care about the number of pixels? Also it's slightly more than 2.3Mpix (2.359296 Mpix) making the comment inaccurate.
2048 *1152 is the smallest common 16:9/4:3 resolution that larger than 1080p, we try to use this resolution as the start point to make imgu work on high frequency.
Quoted 9 lines
drivers/staging/media/ipu3/ipu3-v4l2.c static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, · line 190
Quoted 4 lines
drivers/staging/media/ipu3/ipu3-v4l2.c +3
-0+ imgu->low_power = true; + else + imgu->low_power = false;There should be no need to store this, as we should have access to the exact format when we start streaming. Could you move the check there?
Also, we have 2 pipes. How do they play together?
We want to guarantee 2 pipes can always work on each frequency, there is no precise calculation which can be used to make more finer granularity.
Quoted 4 lines
Best regards,
Tomasz
Quoted 85 lines · Bingbu Cao
Hi, Tomasz
Thanks for your review.
Quoted 32 lines · Tomasz Figa
Hi Bingbu,
Quoted 9 lines · On Fri, Aug 16, 2019 at 12:25 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 2.3MP), the imgu did not need work in high frequency.
This patch make imgu work on 200MHz if the imgu input frame is less than 2.3MP to save power.Thanks for the patch! Please see my comments inline.
Quoted 17 lines
Signed-off-by Bingbu Cao <[email protected]>--- drivers/staging/media/ipu3/ipu3-css.c | 7 ++++--- drivers/staging/media/ipu3/ipu3-css.h | 3 ++- drivers/staging/media/ipu3/ipu3-v4l2.c | 6 ++++++ drivers/staging/media/ipu3/ipu3.c | 6 ++++-- drivers/staging/media/ipu3/ipu3.h | 1 + 5 files changed, 17 insertions(+), 6 deletions(-)drivers/staging/media/ipu3/ipu3-css.c +0
-0@@ -210,12 +210,13 @@ static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp)/* Initialize the IPU3 CSS hardware and associated h/w blocks */ Quoted 8 lines
drivers/staging/media/ipu3/ipu3-css.c static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp) · line 215
Quoted 5 lines
drivers/staging/media/ipu3/ipu3-css.c +2
-2-int imgu_css_set_powerup (struct device *dev,void __iomem *base) +int imgu_css_set_powerup (struct device *dev,void __iomem *base,bool low_power) { -static const unsigned int freq =450 ; +unsigned int freq;How about making freq the argument to this function rather than introducing some artificial boolean?
Let me try to move the check into
imgu_powerup().Quoted 23 lines
Quoted 23 lines
drivers/staging/media/ipu3/ipu3-css.c +2
-1u32 pm_ctrl, state, val; -dev_dbg (dev,"%s\n" , __func__); + freq = low_power ?200 :450 ; +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@@ -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, +bool low_power);void imgu_css_set_powerdown (struct device *dev,void __iomem *base);int imgu_css_irq_ack (struct imgu_css *css);Quoted 15 lines
drivers/staging/media/ipu3/ipu3-v4l2.c static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, · line 187
Quoted 11 lines
drivers/staging/media/ipu3/ipu3-v4l2.c +3
-0@@ -182,6 +182,12 @@ static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, fmt->format.height =clamp (fmt->format.height,IPU3_INPUT_MIN_HEIGHT ,IPU3_INPUT_MAX_HEIGHT ); + +/* input less than 2.3MP, ask imgu to work with low freq */ +if ((fmt->format.width * fmt->format.height) < (2048 *1152 ))Why 2048 * 1152 specifically if we just care about the number of pixels? Also it's slightly more than 2.3Mpix (2.359296 Mpix) making the comment inaccurate.
Quoted 3 lines
2048 *1152 is the smallest common 16:9/4:3 resolution that larger than 1080p, we try to use this resolution as the start point to make imgu work on high frequency.
I'm still not sure what's the reason for this particular value. What's exactly the hardware specification for 200 MHz?
Quoted 11 lines
Quoted 9 lines
drivers/staging/media/ipu3/ipu3-v4l2.c static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, · line 190
Quoted 4 lines
drivers/staging/media/ipu3/ipu3-v4l2.c +3
-0+ imgu->low_power = true; + else + imgu->low_power = false;There should be no need to store this, as we should have access to the exact format when we start streaming. Could you move the check there?
Also, we have 2 pipes. How do they play together?
We want to guarantee 2 pipes can always work on each frequency, there is no precise calculation which can be used to make more finer granularity.
i'm not sure I follow. imgu->low_power is a variable common to both pipes, but it can be changed from subdev_s_fmt() of each pipe separately.
Consider this example:
- pipe 0 s_fmt 2048x1536 -> low_power = false;
- pipe 1 s_fmt 1024x768 -> low_power = truel
We end up with low_power despite the resolution on pipe 0 being higher than the thershold.
Best regards,
Tomasz
Quoted 86 lines · Tomasz Figa
Quoted 85 lines · Bingbu Cao
Hi, Tomasz
Thanks for your review.
Quoted 32 lines · Tomasz Figa
Hi Bingbu,
Quoted 9 lines · On Fri, Aug 16, 2019 at 12:25 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 2.3MP), the imgu did not need work in high frequency.
This patch make imgu work on 200MHz if the imgu input frame is less than 2.3MP to save power.Thanks for the patch! Please see my comments inline.
Quoted 17 lines
Signed-off-by Bingbu Cao <[email protected]>--- drivers/staging/media/ipu3/ipu3-css.c | 7 ++++--- drivers/staging/media/ipu3/ipu3-css.h | 3 ++- drivers/staging/media/ipu3/ipu3-v4l2.c | 6 ++++++ drivers/staging/media/ipu3/ipu3.c | 6 ++++-- drivers/staging/media/ipu3/ipu3.h | 1 + 5 files changed, 17 insertions(+), 6 deletions(-)drivers/staging/media/ipu3/ipu3-css.c +0
-0@@ -210,12 +210,13 @@ static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp)/* Initialize the IPU3 CSS hardware and associated h/w blocks */ Quoted 8 lines
drivers/staging/media/ipu3/ipu3-css.c static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp) · line 215
Quoted 5 lines
drivers/staging/media/ipu3/ipu3-css.c +2
-2-int imgu_css_set_powerup (struct device *dev,void __iomem *base) +int imgu_css_set_powerup (struct device *dev,void __iomem *base,bool low_power) { -static const unsigned int freq =450 ; +unsigned int freq;How about making freq the argument to this function rather than introducing some artificial boolean?
Let me try to move the check into
imgu_powerup().Quoted 38 lines
Quoted 28 lines
drivers/staging/media/ipu3/ipu3-css.c +2
-1u32 pm_ctrl, state, val; -dev_dbg (dev,"%s\n" , __func__); + freq = low_power ?200 :450 ; +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@@ -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, +bool low_power);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-v4l2.c +0
-0drivers/staging/media/ipu3/ipu3-v4l2.c static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, · line 187
Quoted 6 lines
drivers/staging/media/ipu3/ipu3-v4l2.c +3
-0@@ -182,6 +182,12 @@ static int imgu_subdev_set_fmt(struct v4l2_subdev *sd, fmt->format.height =clamp (fmt->format.height,IPU3_INPUT_MIN_HEIGHT ,IPU3_INPUT_MAX_HEIGHT ); + +/* input less than 2.3MP, ask imgu to work with low freq */ +if ((fmt->format.width * fmt->format.height) < (2048 *1152 ))Why 2048 * 1152 specifically if we just care about the number of pixels? Also it's slightly more than 2.3Mpix (2.359296 Mpix) making the comment inaccurate.
Quoted 6 lines
Quoted 3 lines
2048 *1152 is the smallest common 16:9/4:3 resolution that larger than 1080p, we try to use this resolution as the start point to make imgu work on high frequency.
I'm still not sure what's the reason for this particular value. What's exactly the hardware specification for 200 MHz?
200MHz is the lowest frequency allowed by hardware, and we validate it can work for current 1080p use cases. 450MHz is the recommend frequency in spec.
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/staging/media/ipu3/ipu3-v4l2.c +3
-0+ imgu->low_power = true; + else + imgu->low_power = false;Quoted 6 lines
Quoted 4 lines
There should be no need to store this, as we should have access to the exact format when we start streaming. Could you move the check there?
Also, we have 2 pipes. How do they play together?
We want to guarantee 2 pipes can always work on each frequency, there is no precise calculation which can be used to make more finer granularity.
i'm not sure I follow.
imgu->low_poweris a variable common to both pipes, but it can be changed fromsubdev_s_fmt()of each pipe separately.
Quoted 6 lines
Consider this example:
- pipe 0s_fmt2048x1536 ->low_power= false;
- pipe 1s_fmt1024x768 ->low_power= truelWe end up with
low_powerdespite the resolution on pipe 0 being higher than the thershold.
I change the behavior in v2, could you help review?
Quoted 4 lines
Best regards,
Tomasz