Skip to contentSkip to conversation

Fix the rkisp1 userspace API for later IP versions

PATCH Superseded Heiko Stuebner 4 participants 9 messages Jan 11, 2021 – Mar 4, 2022

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Heiko Stuebner

author maintainer
#0 lore raw

cover Fix the rkisp1 userspace API for later IP versions

This NEEDs to go into 5.11 while we can still adapt the uapi during its RC-cycle.

When looking into supporting the rkisp1 of the px30 I noticed that some fields got bigger in the uapi, caused by bigger number of samples for example for histograms or gamma values.

The rkisp1 was destaged with 5.11-rc1 so we have still time during the 5.11 cycle to fix that without big hassles.

This was discussed previously in a mail [0] and a rfc series [1] and this two-part series now splits out the important parts that really should become part of a 5.11-rc and thus the final 5.11.

[0] http://lore.kernel.org/r/3342088.iIbC2pHGDl@diego
[1] https://lore.kernel.org/r/[email protected]

Heiko Stuebner (2):
media: rockchip: rkisp1: carry ip version information
media: rockchip: rkisp1: extend uapi array sizes

 .../platform/rockchip/rkisp1/rkisp1-common.h  |  1 +
 .../platform/rockchip/rkisp1/rkisp1-dev.c     | 22 +++++++++-------
 include/uapi/linux/rkisp1-config.h            | 25 ++++++++++++++++---
 3 files changed, 35 insertions(+), 13 deletions(-)
Signature · 7 lines
2.29.2


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author maintainer
#1 lore raw

PATCH 1/2 media: rockchip: rkisp1: carry ip version information

From: Heiko Stuebner <[email protected]>

The IP block evolved from its rk3288/rk3399 base and the vendor designates them with a numerical version. rk3399 for example is designated V10 probably meaning V1.0.

There doesn't seem to be an actual version register we could read that information from, so allow the match_data to carry that information for future differentiation.

Also carry that information in the hw_revision field of the media- controller API, so that userspace also has access to that.

The added versions are:
- V10: at least rk3288 + rk3399
- V11: seemingly unused as of now, but probably appeared in some soc
- V12: at least rk3326 + px30
- V13: at least rk1808

---
changes since rfc:
- move rkisp1_version enum into uapo
- show version in media-api hw_revision

 .../platform/rockchip/rkisp1/rkisp1-common.h  |  1 +
 .../platform/rockchip/rkisp1/rkisp1-dev.c     | 22 +++++++++++--------
 include/uapi/linux/rkisp1-config.h            |  7 ++++++
 3 files changed, 21 insertions(+), 9 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +1 -0
index 038c303a8aed..bad1bd468f2f 100644
@@ -354,6 +354,7 @@ struct rkisp1_device {
 	void __iomem *base_addr;
 	int irq;
 	struct device *dev;
+	enum rkisp1_cif_isp_version isp_ver;
 	unsigned int clk_size;
 	struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK];
 	struct v4l2_device v4l2_dev;
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +13 -9
index 68da1eed753d..f594d7cd03d0 100644
@@ -104,6 +104,7 @@
 struct rkisp1_match_data {
 	const char * const *clks;
 	unsigned int size;
+	enum rkisp1_cif_isp_version isp_ver;
 };
 
 /* ----------------------------------------------------------------------------
@@ -411,15 +412,16 @@ static const char * const rk3399_isp_clks[] = {
 	"hclk",
 };
 
-static const struct rkisp1_match_data rk3399_isp_clk_data = {
+static const struct rkisp1_match_data rk3399_isp_match_data = {
 	.clks = rk3399_isp_clks,
 	.size = ARRAY_SIZE(rk3399_isp_clks),
+	.isp_ver = RKISP1_V10,
 };
 
 static const struct of_device_id rkisp1_of_match[] = {
 	{
 		.compatible = "rockchip,rk3399-cif-isp",
-		.data = &rk3399_isp_clk_data,
+		.data = &rk3399_isp_match_data,
 	},
 	{},
 };
@@ -457,15 +459,15 @@ static void rkisp1_debug_init(struct rkisp1_device *rkisp1)
 
 static int rkisp1_probe(struct platform_device *pdev)
 {
-	const struct rkisp1_match_data *clk_data;
+	const struct rkisp1_match_data *match_data;
 	struct device *dev = &pdev->dev;
 	struct rkisp1_device *rkisp1;
 	struct v4l2_device *v4l2_dev;
 	unsigned int i;
 	int ret, irq;
 
-	clk_data = of_device_get_match_data(&pdev->dev);
-	if (!clk_data)
+	match_data = of_device_get_match_data(&pdev->dev);
+	if (!match_data)
 		return -ENODEV;
 
 	rkisp1 = devm_kzalloc(dev, sizeof(*rkisp1), GFP_KERNEL);
@@ -494,15 +496,17 @@ static int rkisp1_probe(struct platform_device *pdev)
 
 	rkisp1->irq = irq;
 
-	for (i = 0; i < clk_data->size; i++)
-		rkisp1->clks[i].id = clk_data->clks[i];
-	ret = devm_clk_bulk_get(dev, clk_data->size, rkisp1->clks);
+	for (i = 0; i < match_data->size; i++)
+		rkisp1->clks[i].id = match_data->clks[i];
+	ret = devm_clk_bulk_get(dev, match_data->size, rkisp1->clks);
 	if (ret)
 		return ret;
-	rkisp1->clk_size = clk_data->size;
+	rkisp1->clk_size = match_data->size;
+	rkisp1->isp_ver = match_data->isp_ver;
 
 	pm_runtime_enable(&pdev->dev);
 
+	rkisp1->media_dev.hw_revision = rkisp1->isp_ver;
 	strscpy(rkisp1->media_dev.model, RKISP1_DRIVER_NAME,
 		sizeof(rkisp1->media_dev.model));
 	rkisp1->media_dev.dev = &pdev->dev;
include/uapi/linux/rkisp1-config.h +7 -0
index 6e449e784260..bad46aadf838 100644
@@ -124,6 +124,13 @@
 #define RKISP1_CIF_ISP_STAT_AFM           (1U << 2)
 #define RKISP1_CIF_ISP_STAT_HIST          (1U << 3)
 
+enum rkisp1_cif_isp_version {
+	RKISP1_V10 = 0,
+	RKISP1_V11,
+	RKISP1_V12,
+	RKISP1_V13,
+};
+
 enum rkisp1_cif_isp_histogram_mode {
 	RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
 	RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,
Signature · 7 lines
2.29.2


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#2 lore raw

Re: [PATCH 1/2] media: rockchip: rkisp1: carry ip version information

Quoted 101 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

The IP block evolved from its rk3288/rk3399 base and the vendor designates them with a numerical version. rk3399 for example is designated V10 probably meaning V1.0.

There doesn't seem to be an actual version register we could read that information from, so allow the match_data to carry that information for future differentiation.

Also carry that information in the hw_revision field of the media- controller API, so that userspace also has access to that.

The added versions are:
- V10: at least rk3288 + rk3399
- V11: seemingly unused as of now, but probably appeared in some soc
- V12: at least rk3326 + px30
- V13: at least rk1808

---
changes since rfc:
- move rkisp1_version enum into uapo
- show version in media-api hw_revision

 .../platform/rockchip/rkisp1/rkisp1-common.h  |  1 +
 .../platform/rockchip/rkisp1/rkisp1-dev.c     | 22 +++++++++++--------
 include/uapi/linux/rkisp1-config.h            |  7 ++++++
 3 files changed, 21 insertions(+), 9 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +1 -0
index 038c303a8aed..bad1bd468f2f 100644
@@ -354,6 +354,7 @@ struct rkisp1_device {
 	void __iomem *base_addr;
 	int irq;
 	struct device *dev;
+	enum rkisp1_cif_isp_version isp_ver;
 	unsigned int clk_size;
 	struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK];
 	struct v4l2_device v4l2_dev;
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +9 -8
index 68da1eed753d..f594d7cd03d0 100644
@@ -104,6 +104,7 @@
 struct rkisp1_match_data {
 	const char * const *clks;
 	unsigned int size;
+	enum rkisp1_cif_isp_version isp_ver;
 };
 
 /* ----------------------------------------------------------------------------
@@ -411,15 +412,16 @@ static const char * const rk3399_isp_clks[] = {
 	"hclk",
 };
 
-static const struct rkisp1_match_data rk3399_isp_clk_data = {
+static const struct rkisp1_match_data rk3399_isp_match_data = {
 	.clks = rk3399_isp_clks,
 	.size = ARRAY_SIZE(rk3399_isp_clks),
+	.isp_ver = RKISP1_V10,
 };
 
 static const struct of_device_id rkisp1_of_match[] = {
 	{
 		.compatible = "rockchip,rk3399-cif-isp",
-		.data = &rk3399_isp_clk_data,
+		.data = &rk3399_isp_match_data,
 	},
 	{},
 };
@@ -457,15 +459,15 @@ static void rkisp1_debug_init(struct rkisp1_device *rkisp1)
 
 static int rkisp1_probe(struct platform_device *pdev)
 {
-	const struct rkisp1_match_data *clk_data;
+	const struct rkisp1_match_data *match_data;
 	struct device *dev = &pdev->dev;
 	struct rkisp1_device *rkisp1;
 	struct v4l2_device *v4l2_dev;
 	unsigned int i;
 	int ret, irq;
 
-	clk_data = of_device_get_match_data(&pdev->dev);
-	if (!clk_data)
+	match_data = of_device_get_match_data(&pdev->dev);
+	if (!match_data)
 		return -ENODEV;
 
 	rkisp1 = devm_kzalloc(dev, sizeof(*rkisp1), GFP_KERNEL);
@@ -494,15 +496,17 @@ static int rkisp1_probe(struct platform_device *pdev)
 
 	rkisp1->irq = irq;
 
-	for (i = 0; i < clk_data->size; i++)
-		rkisp1->clks[i].id = clk_data->clks[i];
-	ret = devm_clk_bulk_get(dev, clk_data->size, rkisp1->clks);
+	for (i = 0; i < match_data->size; i++)
+		rkisp1->clks[i].id = match_data->clks[i];

drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c static int rkisp1_probe(struct platform_device *pdev) · line 509

Quoted 10 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +4 -1
+	ret = devm_clk_bulk_get(dev, match_data->size, rkisp1->clks);
 	if (ret)
 		return ret;
-	rkisp1->clk_size = clk_data->size;
+	rkisp1->clk_size = match_data->size;
+	rkisp1->isp_ver = match_data->isp_ver;
 
 	pm_runtime_enable(&pdev->dev);
 
+	rkisp1->media_dev.hw_revision = rkisp1->isp_ver;

This must be documented in Documentation/media/admin-guide/rkisp1.rst. Document that this field is used by this driver and the mapping of the version number to SoCs.

Quoted 12 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +0 -0
 	strscpy(rkisp1->media_dev.model, RKISP1_DRIVER_NAME,
 		sizeof(rkisp1->media_dev.model));
 	rkisp1->media_dev.dev = &pdev->dev;
include/uapi/linux/rkisp1-config.h +0 -0
index 6e449e784260..bad46aadf838 100644
@@ -124,6 +124,13 @@
 #define RKISP1_CIF_ISP_STAT_AFM           (1U << 2)
 #define RKISP1_CIF_ISP_STAT_HIST          (1U << 3)
 

include/uapi/linux/rkisp1-config.h line 136

Quoted 10 lines
include/uapi/linux/rkisp1-config.h +7 -0
+enum rkisp1_cif_isp_version {
+	RKISP1_V10 = 0,
+	RKISP1_V11,
+	RKISP1_V12,
+	RKISP1_V13,
+};
+
 enum rkisp1_cif_isp_histogram_mode {
 	RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
 	RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,

Regards,

Hans

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#3 lore raw

Re: [PATCH 1/2] media: rockchip: rkisp1: carry ip version information

Am 12.01.21 um 09:32 schrieb Hans Verkuil:

Quoted 10 lines · Heiko Stuebner
Quoted 9 lines

From: Heiko Stuebner <[email protected]>

The IP block evolved from its rk3288/rk3399 base and the vendor designates them with a numerical version. rk3399 for example is designated V10 probably meaning V1.0.

There doesn't seem to be an actual version register we could read that information from, so allow the match_data to carry that information for future differentiation.

There is a register RKISP1_CIF_VI_ID.
The datasheet I have says: "MARVIN revision ID"
The datasheet says that the reset value is 1085'3017H
which is also the value for the rk3399 and is described "M14_v2 id (Rel. 1.1)"

I don't how this register corresponds to the versions from the downstream code if at all.

The register is read and kprinted in function rkisp1_config_cif Could you report the value printed in the px30?

Quoted 21 lines
Quoted 21 lines

Also carry that information in the hw_revision field of the media- controller API, so that userspace also has access to that.

The added versions are:
- V10: at least rk3288 + rk3399
- V11: seemingly unused as of now, but probably appeared in some soc
- V12: at least rk3326 + px30
- V13: at least rk1808

---
changes since rfc:
- move rkisp1_version enum into uapo
- show version in media-api hw_revision

  .../platform/rockchip/rkisp1/rkisp1-common.h  |  1 +
  .../platform/rockchip/rkisp1/rkisp1-dev.c     | 22 +++++++++++--------
  include/uapi/linux/rkisp1-config.h            |  7 ++++++
  3 files changed, 21 insertions(+), 9 deletions(-)
Quoted 9 lines

drivers/media/platform/rockchip/rkisp1/rkisp1-common.h struct rkisp1_device { · line 357

Quoted 9 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +1 -0
index 038c303a8aed..bad1bd468f2f 100644
@@ -354,6 +354,7 @@ struct rkisp1_device {
  	void __iomem *base_addr;
  	int irq;
  	struct device *dev;
+	enum rkisp1_cif_isp_version isp_ver;

I don't think we need to add this field, seems to be enough to set the media_dev.hw_revision

Thanks,
Dafna

Quoted 102 lines
Quoted 62 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +0 -0
  	unsigned int clk_size;
  	struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK];
  	struct v4l2_device v4l2_dev;
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +9 -8
index 68da1eed753d..f594d7cd03d0 100644
@@ -104,6 +104,7 @@
  struct rkisp1_match_data {
  	const char * const *clks;
  	unsigned int size;
+	enum rkisp1_cif_isp_version isp_ver;
  };
 
  /* ----------------------------------------------------------------------------
@@ -411,15 +412,16 @@ static const char * const rk3399_isp_clks[] = {
  	"hclk",
  };
 
-static const struct rkisp1_match_data rk3399_isp_clk_data = {
+static const struct rkisp1_match_data rk3399_isp_match_data = {
  	.clks = rk3399_isp_clks,
  	.size = ARRAY_SIZE(rk3399_isp_clks),
+	.isp_ver = RKISP1_V10,
  };
 
  static const struct of_device_id rkisp1_of_match[] = {
  	{
  		.compatible = "rockchip,rk3399-cif-isp",
-		.data = &rk3399_isp_clk_data,
+		.data = &rk3399_isp_match_data,
  	},
  	{},
  };
@@ -457,15 +459,15 @@ static void rkisp1_debug_init(struct rkisp1_device *rkisp1)
 
  static int rkisp1_probe(struct platform_device *pdev)
  {
-	const struct rkisp1_match_data *clk_data;
+	const struct rkisp1_match_data *match_data;
  	struct device *dev = &pdev->dev;
  	struct rkisp1_device *rkisp1;
  	struct v4l2_device *v4l2_dev;
  	unsigned int i;
  	int ret, irq;
 
-	clk_data = of_device_get_match_data(&pdev->dev);
-	if (!clk_data)
+	match_data = of_device_get_match_data(&pdev->dev);
+	if (!match_data)
  		return -ENODEV;
 
  	rkisp1 = devm_kzalloc(dev, sizeof(*rkisp1), GFP_KERNEL);
@@ -494,15 +496,17 @@ static int rkisp1_probe(struct platform_device *pdev)
 
  	rkisp1->irq = irq;
 
-	for (i = 0; i < clk_data->size; i++)
-		rkisp1->clks[i].id = clk_data->clks[i];
-	ret = devm_clk_bulk_get(dev, clk_data->size, rkisp1->clks);
+	for (i = 0; i < match_data->size; i++)
+		rkisp1->clks[i].id = match_data->clks[i];

drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c static int rkisp1_probe(struct platform_device *pdev) · line 509

Quoted 10 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +4 -1
+	ret = devm_clk_bulk_get(dev, match_data->size, rkisp1->clks);
  	if (ret)
  		return ret;
-	rkisp1->clk_size = clk_data->size;
+	rkisp1->clk_size = match_data->size;
+	rkisp1->isp_ver = match_data->isp_ver;
 
  	pm_runtime_enable(&pdev->dev);
 
+	rkisp1->media_dev.hw_revision = rkisp1->isp_ver;

This must be documented in Documentation/media/admin-guide/rkisp1.rst. Document that this field is used by this driver and the mapping of the version number to SoCs.

Quoted 12 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +0 -0
  	strscpy(rkisp1->media_dev.model, RKISP1_DRIVER_NAME,
  		sizeof(rkisp1->media_dev.model));
  	rkisp1->media_dev.dev = &pdev->dev;
include/uapi/linux/rkisp1-config.h +0 -0
index 6e449e784260..bad46aadf838 100644
@@ -124,6 +124,13 @@
  #define RKISP1_CIF_ISP_STAT_AFM           (1U << 2)
  #define RKISP1_CIF_ISP_STAT_HIST          (1U << 3)
 

include/uapi/linux/rkisp1-config.h line 136

Quoted 10 lines
include/uapi/linux/rkisp1-config.h +7 -0
+enum rkisp1_cif_isp_version {
+	RKISP1_V10 = 0,
+	RKISP1_V11,
+	RKISP1_V12,
+	RKISP1_V13,
+};
+
  enum rkisp1_cif_isp_histogram_mode {
  	RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
  	RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,

Regards,

Quoted 2 lines

Hans

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author maintainer
#4 lore raw

Re: [PATCH 1/2] media: rockchip: rkisp1: carry ip version information

Am Dienstag, 12. Januar 2021, 11:47:57 CET schrieb Dafna Hirschfeld:

Quoted 9 lines

Am 12.01.21 um 09:32 schrieb Hans Verkuil:

Quoted 7 lines · Heiko Stuebner
Quoted 6 lines

From: Heiko Stuebner <[email protected]>

The IP block evolved from its rk3288/rk3399 base and the vendor designates them with a numerical version. rk3399 for example is designated V10 probably meaning V1.0.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

There doesn't seem to be an actual version register we could read that information from, so allow the match_data to carry that information for future differentiation.

There is a register RKISP1_CIF_VI_ID.
The datasheet I have says: "MARVIN revision ID" The datasheet says that the reset value is 1085'3017H

printing CIF_VI_ID on the px30 shows:

	rkisp1 ff4a0000.isp: CIF_ID 0x09305366

though I also can't guess what that should mean.

Quoted 29 lines

which is also the value for the rk3399 and is described "M14_v2 id (Rel. 1.1)"

I don't how this register corresponds to the versions from the downstream code if at all.

The register is read and kprinted in function rkisp1_config_cif Could you report the value printed in the px30?

Quoted 21 lines
Quoted 21 lines

Also carry that information in the hw_revision field of the media- controller API, so that userspace also has access to that.

The added versions are:
- V10: at least rk3288 + rk3399
- V11: seemingly unused as of now, but probably appeared in some soc
- V12: at least rk3326 + px30
- V13: at least rk1808

---
changes since rfc:
- move rkisp1_version enum into uapo
- show version in media-api hw_revision

  .../platform/rockchip/rkisp1/rkisp1-common.h  |  1 +
  .../platform/rockchip/rkisp1/rkisp1-dev.c     | 22 +++++++++++--------
  include/uapi/linux/rkisp1-config.h            |  7 ++++++
  3 files changed, 21 insertions(+), 9 deletions(-)
Quoted 12 lines
Quoted 9 lines

drivers/media/platform/rockchip/rkisp1/rkisp1-common.h struct rkisp1_device { · line 357

Quoted 9 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +1 -0
index 038c303a8aed..bad1bd468f2f 100644
@@ -354,6 +354,7 @@ struct rkisp1_device {
  	void __iomem *base_addr;
  	int irq;
  	struct device *dev;
+	enum rkisp1_cif_isp_version isp_ver;

I don't think we need to add this field, seems to be enough to set the media_dev.hw_revision

you're right, one instance in media_dev.hw_revision should be enough Will change that in v2.

Heiko

Quoted 102 lines
Quoted 102 lines
Quoted 62 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +0 -0
  	unsigned int clk_size;
  	struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK];
  	struct v4l2_device v4l2_dev;
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +9 -8
index 68da1eed753d..f594d7cd03d0 100644
@@ -104,6 +104,7 @@
  struct rkisp1_match_data {
  	const char * const *clks;
  	unsigned int size;
+	enum rkisp1_cif_isp_version isp_ver;
  };
 
  /* ----------------------------------------------------------------------------
@@ -411,15 +412,16 @@ static const char * const rk3399_isp_clks[] = {
  	"hclk",
  };
 
-static const struct rkisp1_match_data rk3399_isp_clk_data = {
+static const struct rkisp1_match_data rk3399_isp_match_data = {
  	.clks = rk3399_isp_clks,
  	.size = ARRAY_SIZE(rk3399_isp_clks),
+	.isp_ver = RKISP1_V10,
  };
 
  static const struct of_device_id rkisp1_of_match[] = {
  	{
  		.compatible = "rockchip,rk3399-cif-isp",
-		.data = &rk3399_isp_clk_data,
+		.data = &rk3399_isp_match_data,
  	},
  	{},
  };
@@ -457,15 +459,15 @@ static void rkisp1_debug_init(struct rkisp1_device *rkisp1)
 
  static int rkisp1_probe(struct platform_device *pdev)
  {
-	const struct rkisp1_match_data *clk_data;
+	const struct rkisp1_match_data *match_data;
  	struct device *dev = &pdev->dev;
  	struct rkisp1_device *rkisp1;
  	struct v4l2_device *v4l2_dev;
  	unsigned int i;
  	int ret, irq;
 
-	clk_data = of_device_get_match_data(&pdev->dev);
-	if (!clk_data)
+	match_data = of_device_get_match_data(&pdev->dev);
+	if (!match_data)
  		return -ENODEV;
 
  	rkisp1 = devm_kzalloc(dev, sizeof(*rkisp1), GFP_KERNEL);
@@ -494,15 +496,17 @@ static int rkisp1_probe(struct platform_device *pdev)
 
  	rkisp1->irq = irq;
 
-	for (i = 0; i < clk_data->size; i++)
-		rkisp1->clks[i].id = clk_data->clks[i];
-	ret = devm_clk_bulk_get(dev, clk_data->size, rkisp1->clks);
+	for (i = 0; i < match_data->size; i++)
+		rkisp1->clks[i].id = match_data->clks[i];

drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c static int rkisp1_probe(struct platform_device *pdev) · line 509

Quoted 10 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +4 -1
+	ret = devm_clk_bulk_get(dev, match_data->size, rkisp1->clks);
  	if (ret)
  		return ret;
-	rkisp1->clk_size = clk_data->size;
+	rkisp1->clk_size = match_data->size;
+	rkisp1->isp_ver = match_data->isp_ver;
 
  	pm_runtime_enable(&pdev->dev);
 
+	rkisp1->media_dev.hw_revision = rkisp1->isp_ver;

This must be documented in Documentation/media/admin-guide/rkisp1.rst. Document that this field is used by this driver and the mapping of the version number to SoCs.

Quoted 12 lines
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +0 -0
  	strscpy(rkisp1->media_dev.model, RKISP1_DRIVER_NAME,
  		sizeof(rkisp1->media_dev.model));
  	rkisp1->media_dev.dev = &pdev->dev;
include/uapi/linux/rkisp1-config.h +0 -0
index 6e449e784260..bad46aadf838 100644
@@ -124,6 +124,13 @@
  #define RKISP1_CIF_ISP_STAT_AFM           (1U << 2)
  #define RKISP1_CIF_ISP_STAT_HIST          (1U << 3)
 

include/uapi/linux/rkisp1-config.h line 136

Quoted 10 lines
include/uapi/linux/rkisp1-config.h +7 -0
+enum rkisp1_cif_isp_version {
+	RKISP1_V10 = 0,
+	RKISP1_V11,
+	RKISP1_V12,
+	RKISP1_V13,
+};
+
  enum rkisp1_cif_isp_histogram_mode {
  	RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
  	RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,

Regards,

Quoted 3 lines
Quoted 2 lines

Hans

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

maintainer
#5 lore raw

Re: [PATCH 1/2] media: rockchip: rkisp1: carry ip version information

In reply to Heiko Stuebner

Hi Heiko,

Reviving a bit of an older thread.

Quoted 13 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

The IP block evolved from its rk3288/rk3399 base and the vendor designates them with a numerical version. rk3399 for example is designated V10 probably meaning V1.0.

There doesn't seem to be an actual version register we could read that information from, so allow the match_data to carry that information for future differentiation.

Also carry that information in the hw_revision field of the media- controller API, so that userspace also has access to that.

Quoted 7 lines

The added versions are:
- V10: at least rk3288 + rk3399
- V11: seemingly unused as of now, but probably appeared in some soc
- V12: at least rk3326 + px30
- V13: at least rk1808

The ISP has a version register, which is read at streamon time and printed in a dev_dbg() message. On RK3399 it reads as 0x30153017, and I was wondering what values are returned for other SoCs. Would you be able to test on the other platforms you have access to ?

Quoted 112 lines

---
changes since rfc:
- move rkisp1_version enum into uapo
- show version in media-api hw_revision

 .../platform/rockchip/rkisp1/rkisp1-common.h  |  1 +
 .../platform/rockchip/rkisp1/rkisp1-dev.c     | 22 +++++++++++--------
 include/uapi/linux/rkisp1-config.h            |  7 ++++++
 3 files changed, 21 insertions(+), 9 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +1 -0
index 038c303a8aed..bad1bd468f2f 100644
@@ -354,6 +354,7 @@ struct rkisp1_device {
 	void __iomem *base_addr;
 	int irq;
 	struct device *dev;
+	enum rkisp1_cif_isp_version isp_ver;
 	unsigned int clk_size;
 	struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK];
 	struct v4l2_device v4l2_dev;
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +13 -9
index 68da1eed753d..f594d7cd03d0 100644
@@ -104,6 +104,7 @@
 struct rkisp1_match_data {
 	const char * const *clks;
 	unsigned int size;
+	enum rkisp1_cif_isp_version isp_ver;
 };
 
 /* ----------------------------------------------------------------------------
@@ -411,15 +412,16 @@ static const char * const rk3399_isp_clks[] = {
 	"hclk",
 };
 
-static const struct rkisp1_match_data rk3399_isp_clk_data = {
+static const struct rkisp1_match_data rk3399_isp_match_data = {
 	.clks = rk3399_isp_clks,
 	.size = ARRAY_SIZE(rk3399_isp_clks),
+	.isp_ver = RKISP1_V10,
 };
 
 static const struct of_device_id rkisp1_of_match[] = {
 	{
 		.compatible = "rockchip,rk3399-cif-isp",
-		.data = &rk3399_isp_clk_data,
+		.data = &rk3399_isp_match_data,
 	},
 	{},
 };
@@ -457,15 +459,15 @@ static void rkisp1_debug_init(struct rkisp1_device *rkisp1)
 
 static int rkisp1_probe(struct platform_device *pdev)
 {
-	const struct rkisp1_match_data *clk_data;
+	const struct rkisp1_match_data *match_data;
 	struct device *dev = &pdev->dev;
 	struct rkisp1_device *rkisp1;
 	struct v4l2_device *v4l2_dev;
 	unsigned int i;
 	int ret, irq;
 
-	clk_data = of_device_get_match_data(&pdev->dev);
-	if (!clk_data)
+	match_data = of_device_get_match_data(&pdev->dev);
+	if (!match_data)
 		return -ENODEV;
 
 	rkisp1 = devm_kzalloc(dev, sizeof(*rkisp1), GFP_KERNEL);
@@ -494,15 +496,17 @@ static int rkisp1_probe(struct platform_device *pdev)
 
 	rkisp1->irq = irq;
 
-	for (i = 0; i < clk_data->size; i++)
-		rkisp1->clks[i].id = clk_data->clks[i];
-	ret = devm_clk_bulk_get(dev, clk_data->size, rkisp1->clks);
+	for (i = 0; i < match_data->size; i++)
+		rkisp1->clks[i].id = match_data->clks[i];
+	ret = devm_clk_bulk_get(dev, match_data->size, rkisp1->clks);
 	if (ret)
 		return ret;
-	rkisp1->clk_size = clk_data->size;
+	rkisp1->clk_size = match_data->size;
+	rkisp1->isp_ver = match_data->isp_ver;
 
 	pm_runtime_enable(&pdev->dev);
 
+	rkisp1->media_dev.hw_revision = rkisp1->isp_ver;
 	strscpy(rkisp1->media_dev.model, RKISP1_DRIVER_NAME,
 		sizeof(rkisp1->media_dev.model));
 	rkisp1->media_dev.dev = &pdev->dev;
include/uapi/linux/rkisp1-config.h +7 -0
index 6e449e784260..bad46aadf838 100644
@@ -124,6 +124,13 @@
 #define RKISP1_CIF_ISP_STAT_AFM           (1U << 2)
 #define RKISP1_CIF_ISP_STAT_HIST          (1U << 3)
 
+enum rkisp1_cif_isp_version {
+	RKISP1_V10 = 0,
+	RKISP1_V11,
+	RKISP1_V12,
+	RKISP1_V13,
+};
+
 enum rkisp1_cif_isp_histogram_mode {
 	RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
 	RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#6 lore raw

PATCH 2/2 media: rockchip: rkisp1: extend uapi array sizes

In reply to Heiko Stuebner

From: Heiko Stuebner <[email protected]>

Later variants of the rkisp1 block use more entries in some arrays:

RKISP1_CIF_ISP_AE_MEAN_MAX                 25 -> 81
RKISP1_CIF_ISP_HIST_BIN_N_MAX              16 -> 32
RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       17 -> 34

RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 28 -> 81

and we can still extend the uapi during the 5.11-rc cycle, so do that now to be on the safe side.

V10 and V11 only need the smaller sizes, while V12 and V13 needed the larger sizes.

---
changes since rfc:
- introduce constants for versions and make max use the biggest

 include/uapi/linux/rkisp1-config.h | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
include/uapi/linux/rkisp1-config.h +14 -4
index bad46aadf838..20d24656a8b7 100644
@@ -49,8 +49,14 @@
 #define RKISP1_CIF_ISP_CTK_COEFF_MAX            0x100
 #define RKISP1_CIF_ISP_CTK_OFFSET_MAX           0x800
 
-#define RKISP1_CIF_ISP_AE_MEAN_MAX              25
-#define RKISP1_CIF_ISP_HIST_BIN_N_MAX           16
+#define RKISP1_CIF_ISP_AE_MEAN_MAX_V10		25
+#define RKISP1_CIF_ISP_AE_MEAN_MAX_V12		81
+#define RKISP1_CIF_ISP_AE_MEAN_MAX		RKISP1_CIF_ISP_AE_MEAN_MAX_V12
+
+#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10	16
+#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12	32
+#define RKISP1_CIF_ISP_HIST_BIN_N_MAX		RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12
+
 #define RKISP1_CIF_ISP_AFM_MAX_WINDOWS          3
 #define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE       17
 
@@ -86,7 +92,9 @@
  * Gamma out
  */
 /* Maximum number of color samples supported */
-#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       17
+#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10   17
+#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12   34
+#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
 
 /*
  * Lens shade correction
@@ -103,7 +111,9 @@
  * Histogram calculation
  */
 /* Last 3 values unused. */
-#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 28
+#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 28
+#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81
+#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE     RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
 
 /*
  * Defect Pixel Cluster Correction
Signature · 7 lines
2.29.2


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
#7 lore raw

Re: [PATCH 2/2] media: rockchip: rkisp1: extend uapi array sizes

Quoted 57 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

Later variants of the rkisp1 block use more entries in some arrays:

RKISP1_CIF_ISP_AE_MEAN_MAX                 25 -> 81
RKISP1_CIF_ISP_HIST_BIN_N_MAX              16 -> 32
RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       17 -> 34

RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 28 -> 81

and we can still extend the uapi during the 5.11-rc cycle, so do that now to be on the safe side.

V10 and V11 only need the smaller sizes, while V12 and V13 needed the larger sizes.

---
changes since rfc:
- introduce constants for versions and make max use the biggest

 include/uapi/linux/rkisp1-config.h | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
include/uapi/linux/rkisp1-config.h +11 -3
index bad46aadf838..20d24656a8b7 100644
@@ -49,8 +49,14 @@
 #define RKISP1_CIF_ISP_CTK_COEFF_MAX            0x100
 #define RKISP1_CIF_ISP_CTK_OFFSET_MAX           0x800
 
-#define RKISP1_CIF_ISP_AE_MEAN_MAX              25
-#define RKISP1_CIF_ISP_HIST_BIN_N_MAX           16
+#define RKISP1_CIF_ISP_AE_MEAN_MAX_V10		25
+#define RKISP1_CIF_ISP_AE_MEAN_MAX_V12		81
+#define RKISP1_CIF_ISP_AE_MEAN_MAX		RKISP1_CIF_ISP_AE_MEAN_MAX_V12
+
+#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10	16
+#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12	32
+#define RKISP1_CIF_ISP_HIST_BIN_N_MAX		RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12
+
 #define RKISP1_CIF_ISP_AFM_MAX_WINDOWS          3
 #define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE       17
 
@@ -86,7 +92,9 @@
  * Gamma out
  */
 /* Maximum number of color samples supported */
-#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       17
+#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10   17
+#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12   34
+#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
 
 /*
  * Lens shade correction

include/uapi/linux/rkisp1-config.h line 119

Quoted 10 lines
include/uapi/linux/rkisp1-config.h +3 -1
@@ -103,7 +111,9 @@
  * Histogram calculation
  */
 /* Last 3 values unused. */
-#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 28
+#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 28
+#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81
+#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE     RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
 
 /*
  * Defect Pixel Cluster Correction

You must update the documentation in this header for the relevant structs as well, including a mention that this depends on hw_revision.

What happens to the unused parts of these arrays on a V10/V11 SoC? Are they zeroed? Please check that no kernel memory contents is leaked in the unused parts.

Regards,

Hans

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

maintainer
#8 lore raw
In reply to Heiko Stuebner

Hi Heiko,

Quoted 7 lines · Heiko Stuebner

This NEEDs to go into 5.11 while we can still adapt the uapi during its RC-cycle.

When looking into supporting the rkisp1 of the px30 I noticed that some fields got bigger in the uapi, caused by bigger number of samples for example for histograms or gamma values.

As I don't have access to a PX30 platform, I was wondering if you could read the RKISP1_CIF_VI_ID register and report its value.

Quoted 19 lines

The rkisp1 was destaged with 5.11-rc1 so we have still time during the 5.11 cycle to fix that without big hassles.

This was discussed previously in a mail [0] and a rfc series [1] and this two-part series now splits out the important parts that really should become part of a 5.11-rc and thus the final 5.11.

[0] http://lore.kernel.org/r/3342088.iIbC2pHGDl@diego
[1] https://lore.kernel.org/r/[email protected]

Heiko Stuebner (2):
media: rockchip: rkisp1: carry ip version information
media: rockchip: rkisp1: extend uapi array sizes

 .../platform/rockchip/rkisp1/rkisp1-common.h  |  1 +
 .../platform/rockchip/rkisp1/rkisp1-dev.c     | 22 +++++++++-------
 include/uapi/linux/rkisp1-config.h            | 25 ++++++++++++++++---
 3 files changed, 35 insertions(+), 13 deletions(-)
Signature · 3 lines
Regards,

Laurent Pinchart