mbox series

[0/6] Add support for SDM630/660 Camera Subsystem

Message ID 20201018125237.16717-1-kholk11@gmail.com
Headers show
Series Add support for SDM630/660 Camera Subsystem | expand

Message

AngeloGioacchino Del Regno Oct. 18, 2020, 12:52 p.m. UTC
From: AngeloGioacchino Del Regno <kholk11@gmail.com>

This patch series implements support for the entire camera subsystem
found in SDM630/636/660 and SDA variants, including CSIPHY 3-Phase,
CSID v5.0, ISPIF 3.0 (though it didn't need any adaptation) and
VFE 4.8.

One small note about VFE4.8, even if I wrote it in the commit that
adds support for it: I know, the VFE support here is split in
multiple files having the name of the actual VFE version that it is
targeting... but it didn't feel right to commonize the VFE 4.7 file
and make another one only for VFE4.8, when it's just about something
like 3 small differences.
That VFE 4.8 seems to be just a minor revision of VFE 4.7.

While at it, also fix a small issue when using two VFEs: only one
of them was being resetted (always VFE0) so, after the first usage
of VFE1, in case we leave it in a bad state, it would not properly
start again. Now... it's fine :)))

P.S.: SDM630/660's camss seems to be *very* similar to MSM8998, so
      likely 90% of this series should be reusable on that one, too!

Tested on:
 - Sony Xperia XA2 (IMX300 on CSI0/PHY0/VFE0, IMX219 on CSI2,PHY2,VFE1)
   * VFE0/1 RDI only, as the VIDEO one does not work with SRGGB Bayer
     formats yet. As far as I can see, that color format hasn't been
     implemented yet in the video interface.

AngeloGioacchino Del Regno (6):
  media: camss: csiphy-3ph: Add support for SDM630/660
  media: camss: ispif: Correctly reset based on the VFE ID
  media: camss: vfe: Add support for VFE 4.8
  media: camss: Add support for SDM630/636/660 camera subsystem
  media: dt-bindings: media: qcom,camss: Add bindings for SDM660 camss
  media: camss: csiphy: Set rate on csiX_phy clock on SDM630/660

 .../devicetree/bindings/media/qcom,camss.txt  |   7 +
 .../media/platform/qcom/camss/camss-csid.c    |   9 +-
 .../qcom/camss/camss-csiphy-3ph-1-0.c         |   7 +-
 .../media/platform/qcom/camss/camss-csiphy.c  |  25 ++-
 .../media/platform/qcom/camss/camss-csiphy.h  |   1 +
 .../media/platform/qcom/camss/camss-ispif.c   | 100 ++++++---
 .../media/platform/qcom/camss/camss-ispif.h   |   2 +-
 .../media/platform/qcom/camss/camss-vfe-4-7.c | 129 ++++++++++-
 drivers/media/platform/qcom/camss/camss-vfe.c |  19 +-
 drivers/media/platform/qcom/camss/camss-vfe.h |   1 +
 .../media/platform/qcom/camss/camss-video.c   |   3 +-
 drivers/media/platform/qcom/camss/camss.c     | 206 +++++++++++++++++-
 drivers/media/platform/qcom/camss/camss.h     |   1 +
 13 files changed, 448 insertions(+), 62 deletions(-)

Comments

Robert Foss Oct. 20, 2020, 10:35 a.m. UTC | #1
Looks good to me.

Signed-off-by: Robert Foss <robert.foss@linaro.org>

On Sun, 18 Oct 2020 at 14:53, <kholk11@gmail.com> wrote:
>
> From: AngeloGioacchino Del Regno <kholk11@gmail.com>
>
> The SDM630/660 SoCs (and variants) have another clock source
> for the PHY, which must be set to a rate that's equal or
> greater than the CSI PHY timer clock: failing to do this
> will produce PHY overflows when trying to get a stream from
> a very high bandwidth camera sensor and outputting no frame
> or a partial one.
>
> Since I haven't found any usecase in which the csiX_phy
> clock needs to be higher than the csiXphy_timer, let's just
> set the same rate on both, which seems to work just perfect.
>
> Signed-off-by: AngeloGioacchino Del Regno <kholk11@gmail.com>
> ---
>  .../media/platform/qcom/camss/camss-csiphy.c  | 22 ++++++++++++++++---
>  .../media/platform/qcom/camss/camss-csiphy.h  |  1 +
>  2 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
> index c00f25aac21b..a5d717d022a5 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
> @@ -113,9 +113,7 @@ static int csiphy_set_clock_rates(struct csiphy_device *csiphy)
>         for (i = 0; i < csiphy->nclocks; i++) {
>                 struct camss_clock *clock = &csiphy->clock[i];
>
> -               if (!strcmp(clock->name, "csiphy0_timer") ||
> -                   !strcmp(clock->name, "csiphy1_timer") ||
> -                   !strcmp(clock->name, "csiphy2_timer")) {
> +               if (csiphy->rate_set[i]) {
>                         u8 bpp = csiphy_get_bpp(csiphy->formats,
>                                         csiphy->nformats,
>                                         csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
> @@ -611,6 +609,13 @@ int msm_csiphy_subdev_init(struct camss *camss,
>         if (!csiphy->clock)
>                 return -ENOMEM;
>
> +       csiphy->rate_set = devm_kcalloc(dev,
> +                                       csiphy->nclocks,
> +                                       sizeof(*csiphy->rate_set),
> +                                       GFP_KERNEL);
> +       if (!csiphy->rate_set)
> +               return -ENOMEM;
> +
>         for (i = 0; i < csiphy->nclocks; i++) {
>                 struct camss_clock *clock = &csiphy->clock[i];
>
> @@ -638,6 +643,17 @@ int msm_csiphy_subdev_init(struct camss *camss,
>
>                 for (j = 0; j < clock->nfreqs; j++)
>                         clock->freq[j] = res->clock_rate[i][j];
> +
> +               if (!strcmp(clock->name, "csiphy0_timer") ||
> +                   !strcmp(clock->name, "csiphy1_timer") ||
> +                   !strcmp(clock->name, "csiphy2_timer"))
> +                       csiphy->rate_set[i] = true;
> +
> +               if (camss->version == CAMSS_660 &&
> +                   (!strcmp(clock->name, "csi0_phy") ||
> +                    !strcmp(clock->name, "csi1_phy") ||
> +                    !strcmp(clock->name, "csi2_phy")))
> +                       csiphy->rate_set[i] = true;
>         }
>
>         return 0;
> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/media/platform/qcom/camss/camss-csiphy.h
> index 376f865ad383..f7967ef836dc 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.h
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.h
> @@ -66,6 +66,7 @@ struct csiphy_device {
>         u32 irq;
>         char irq_name[30];
>         struct camss_clock *clock;
> +       bool *rate_set;
>         int nclocks;
>         u32 timer_clk_rate;
>         struct csiphy_config cfg;
> --
> 2.28.0
>
Robert Foss Oct. 20, 2020, 12:01 p.m. UTC | #2
Hey Angelo,

Thanks for submitting this, and fixing other issues as you went.

I sent out some SoBs which should have been Reviewed-bys, so if you
add them to your commit please replace the SoBs with RBs.


Rob.

On Sun, 18 Oct 2020 at 14:52, <kholk11@gmail.com> wrote:
>

> From: AngeloGioacchino Del Regno <kholk11@gmail.com>

>

> This patch series implements support for the entire camera subsystem

> found in SDM630/636/660 and SDA variants, including CSIPHY 3-Phase,

> CSID v5.0, ISPIF 3.0 (though it didn't need any adaptation) and

> VFE 4.8.

>

> One small note about VFE4.8, even if I wrote it in the commit that

> adds support for it: I know, the VFE support here is split in

> multiple files having the name of the actual VFE version that it is

> targeting... but it didn't feel right to commonize the VFE 4.7 file

> and make another one only for VFE4.8, when it's just about something

> like 3 small differences.

> That VFE 4.8 seems to be just a minor revision of VFE 4.7.

>

> While at it, also fix a small issue when using two VFEs: only one

> of them was being resetted (always VFE0) so, after the first usage

> of VFE1, in case we leave it in a bad state, it would not properly

> start again. Now... it's fine :)))

>

> P.S.: SDM630/660's camss seems to be *very* similar to MSM8998, so

>       likely 90% of this series should be reusable on that one, too!

>

> Tested on:

>  - Sony Xperia XA2 (IMX300 on CSI0/PHY0/VFE0, IMX219 on CSI2,PHY2,VFE1)

>    * VFE0/1 RDI only, as the VIDEO one does not work with SRGGB Bayer

>      formats yet. As far as I can see, that color format hasn't been

>      implemented yet in the video interface.

>

> AngeloGioacchino Del Regno (6):

>   media: camss: csiphy-3ph: Add support for SDM630/660

>   media: camss: ispif: Correctly reset based on the VFE ID

>   media: camss: vfe: Add support for VFE 4.8

>   media: camss: Add support for SDM630/636/660 camera subsystem

>   media: dt-bindings: media: qcom,camss: Add bindings for SDM660 camss

>   media: camss: csiphy: Set rate on csiX_phy clock on SDM630/660

>

>  .../devicetree/bindings/media/qcom,camss.txt  |   7 +

>  .../media/platform/qcom/camss/camss-csid.c    |   9 +-

>  .../qcom/camss/camss-csiphy-3ph-1-0.c         |   7 +-

>  .../media/platform/qcom/camss/camss-csiphy.c  |  25 ++-

>  .../media/platform/qcom/camss/camss-csiphy.h  |   1 +

>  .../media/platform/qcom/camss/camss-ispif.c   | 100 ++++++---

>  .../media/platform/qcom/camss/camss-ispif.h   |   2 +-

>  .../media/platform/qcom/camss/camss-vfe-4-7.c | 129 ++++++++++-

>  drivers/media/platform/qcom/camss/camss-vfe.c |  19 +-

>  drivers/media/platform/qcom/camss/camss-vfe.h |   1 +

>  .../media/platform/qcom/camss/camss-video.c   |   3 +-

>  drivers/media/platform/qcom/camss/camss.c     | 206 +++++++++++++++++-

>  drivers/media/platform/qcom/camss/camss.h     |   1 +

>  13 files changed, 448 insertions(+), 62 deletions(-)

>

> --

> 2.28.0

>