2020-04-26 02:32:08

by Jonathan Bakker

[permalink] [raw]
Subject: [PATCH 11/11] media: exynos4-is: Correct parallel port probing

According to the binding doc[1], port A should be reg = 0
and port B reg = 1. Unfortunately, the driver was treating 0
as invalid and 1 as camera port A. Match the binding doc and
make 0=A and 1=B.

[1] Documentation/devicetree/bindings/media/samsung-fimc.txt

Signed-off-by: Jonathan Bakker <[email protected]>
---
drivers/media/platform/exynos4-is/media-dev.c | 18 +++++++++++++-----
drivers/media/platform/exynos4-is/media-dev.h | 1 +
include/media/drv-intf/exynos-fimc.h | 2 +-
3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index a87ebd7913be..9c4fdf726b92 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -418,13 +418,21 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
return ret;
}

- if (WARN_ON(endpoint.base.port == 0) || *index >= FIMC_MAX_SENSORS) {
- of_node_put(ep);
- return -EINVAL;
+ if (fimc_input_is_parallel(endpoint.base.port)) {
+ if (WARN_ON(*index >= FIMC_MAX_PARALLEL)) {
+ of_node_put(ep);
+ return -EINVAL;
+ }
+ pd->mux_id = endpoint.base.port;
+ } else {
+ if (WARN_ON(endpoint.base.port == 0 ||
+ *index >= FIMC_MAX_SENSORS)) {
+ of_node_put(ep);
+ return -EINVAL;
+ }
+ pd->mux_id = (endpoint.base.port - 1) & 0x1;
}

- pd->mux_id = (endpoint.base.port - 1) & 0x1;
-
rem = of_graph_get_remote_port_parent(ep);
of_node_put(ep);
if (rem == NULL) {
diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h
index 4b8f9ac52ebc..7bd93fd11b33 100644
--- a/drivers/media/platform/exynos4-is/media-dev.h
+++ b/drivers/media/platform/exynos4-is/media-dev.h
@@ -29,6 +29,7 @@

#define PINCTRL_STATE_IDLE "idle"

+#define FIMC_MAX_PARALLEL 2
#define FIMC_MAX_SENSORS 4
#define FIMC_MAX_CAMCLKS 2
#define DEFAULT_SENSOR_CLK_FREQ 24000000U
diff --git a/include/media/drv-intf/exynos-fimc.h b/include/media/drv-intf/exynos-fimc.h
index 6b9ef631d6bb..5a07576c378b 100644
--- a/include/media/drv-intf/exynos-fimc.h
+++ b/include/media/drv-intf/exynos-fimc.h
@@ -44,7 +44,7 @@ enum fimc_bus_type {
FIMC_BUS_TYPE_ISP_WRITEBACK = FIMC_BUS_TYPE_LCD_WRITEBACK_B,
};

-#define fimc_input_is_parallel(x) ((x) == 1 || (x) == 2)
+#define fimc_input_is_parallel(x) ((x) == 0 || (x) == 1)
#define fimc_input_is_mipi_csi(x) ((x) == 3 || (x) == 4)

/*
--
2.20.1


2020-07-07 18:48:57

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH 11/11] media: exynos4-is: Correct parallel port probing

Hi Jonathan,

On Sat, Apr 25, 2020 at 07:26:50PM -0700, Jonathan Bakker wrote:
> According to the binding doc[1], port A should be reg = 0
> and port B reg = 1. Unfortunately, the driver was treating 0
> as invalid and 1 as camera port A. Match the binding doc and
> make 0=A and 1=B.
>
> [1] Documentation/devicetree/bindings/media/samsung-fimc.txt
>
> Signed-off-by: Jonathan Bakker <[email protected]>
> ---
> drivers/media/platform/exynos4-is/media-dev.c | 18 +++++++++++++-----
> drivers/media/platform/exynos4-is/media-dev.h | 1 +
> include/media/drv-intf/exynos-fimc.h | 2 +-
> 3 files changed, 15 insertions(+), 6 deletions(-)
>

Thank you for the patch. Please see my comments inline.

> diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
> index a87ebd7913be..9c4fdf726b92 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -418,13 +418,21 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
> return ret;
> }
>
> - if (WARN_ON(endpoint.base.port == 0) || *index >= FIMC_MAX_SENSORS) {
> - of_node_put(ep);
> - return -EINVAL;
> + if (fimc_input_is_parallel(endpoint.base.port)) {
> + if (WARN_ON(*index >= FIMC_MAX_PARALLEL)) {
> + of_node_put(ep);
> + return -EINVAL;
> + }

This check seems to be generic, so could we just move it above the
if/else block?

> + pd->mux_id = endpoint.base.port;
> + } else {
> + if (WARN_ON(endpoint.base.port == 0 ||

Isn't this impossible, since if port == 0, the 'then' branch would've been
taken instead?

Best regards,
Tomasz

2020-07-08 16:16:29

by Sylwester Nawrocki

[permalink] [raw]
Subject: Re: [PATCH 11/11] media: exynos4-is: Correct parallel port probing

Hi,

On 26.04.2020 04:26, Jonathan Bakker wrote:
> According to the binding doc[1], port A should be reg = 0
> and port B reg = 1. Unfortunately, the driver was treating 0
> as invalid and 1 as camera port A. Match the binding doc and
> make 0=A and 1=B.
>
> [1] Documentation/devicetree/bindings/media/samsung-fimc.txt

Thank you for correcting this. I would prefer to correct the binding
documentation instead, so it says reg=1 for A and reg=2 for B.
Then it would also match what we have in dts for Goni and
enum fimc_input in include/media/drv-intf/exynos-fimc.h.


--
Regards,
Sylwester

2020-07-11 18:21:55

by Jonathan Bakker

[permalink] [raw]
Subject: Re: [PATCH 11/11] media: exynos4-is: Correct parallel port probing

Hi Sylwester,

On 2020-07-08 9:15 a.m., Sylwester Nawrocki wrote:
> Hi,
>
> On 26.04.2020 04:26, Jonathan Bakker wrote:
>> According to the binding doc[1], port A should be reg = 0
>> and port B reg = 1. Unfortunately, the driver was treating 0
>> as invalid and 1 as camera port A. Match the binding doc and
>> make 0=A and 1=B.
>>
>> [1] Documentation/devicetree/bindings/media/samsung-fimc.txt
>
> Thank you for correcting this. I would prefer to correct the binding
> documentation instead, so it says reg=1 for A and reg=2 for B.
> Then it would also match what we have in dts for Goni and
> enum fimc_input in include/media/drv-intf/exynos-fimc.h

No problem, that works for me. I'll drop this patch and replace it with one
changing the documentation.

>
>

Thanks,
Jonathan