[git:media_stage/master] media: platform: rzg2l-cru: rzg2l-video: Fix start reception procedure

2024-02-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: platform: rzg2l-cru: rzg2l-video: Fix start reception procedure
Author:  Biju Das 
Date:Tue Feb 13 18:12:33 2024 +

As per section 35.3.1 Starting Reception for the MIPI CSI-2 Input on the
latest hardware manual (R01UH0914EJ0145 Rev.1.45) we need to supply all
the clocks and then release the CRU resets. Currently we are releasing
the resets and then supplying the clocks. So, fix the start reception
procedure.

Signed-off-by: Biju Das 
Link: 
https://lore.kernel.org/r/20240213181233.242316-6-biju.das...@bp.renesas.com
Reviewed-by: Laurent Pinchart 
Signed-off-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 59 ++
 1 file changed, 28 insertions(+), 31 deletions(-)

---

diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c 
b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index d15a9bfcc98b..b16b8af6e8f8 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -489,39 +489,24 @@ static int rzg2l_cru_set_stream(struct rzg2l_cru_dev 
*cru, int on)
 
video_device_pipeline_stop(>vdev);
 
-   pm_runtime_put_sync(cru->dev);
-   clk_disable_unprepare(cru->vclk);
-
return stream_off_ret;
}
 
-   ret = pm_runtime_resume_and_get(cru->dev);
-   if (ret)
-   return ret;
-
-   ret = clk_prepare_enable(cru->vclk);
-   if (ret)
-   goto err_pm_put;
-
ret = rzg2l_cru_mc_validate_format(cru, sd, pad);
if (ret)
-   goto err_vclk_disable;
+   return ret;
 
pipe = media_entity_pipeline(>entity) ? : >vdev.pipe;
ret = video_device_pipeline_start(>vdev, pipe);
if (ret)
-   goto err_vclk_disable;
+   return ret;
 
ret = v4l2_subdev_call(sd, video, pre_streamon, 0);
-   if (ret == -ENOIOCTLCMD)
-   ret = 0;
-   if (ret)
+   if (ret && ret != -ENOIOCTLCMD)
goto pipe_line_stop;
 
ret = v4l2_subdev_call(sd, video, s_stream, 1);
-   if (ret == -ENOIOCTLCMD)
-   ret = 0;
-   if (ret)
+   if (ret && ret != -ENOIOCTLCMD)
goto err_s_stream;
 
return 0;
@@ -532,12 +517,6 @@ err_s_stream:
 pipe_line_stop:
video_device_pipeline_stop(>vdev);
 
-err_vclk_disable:
-   clk_disable_unprepare(cru->vclk);
-
-err_pm_put:
-   pm_runtime_put_sync(cru->dev);
-
return ret;
 }
 
@@ -636,25 +615,33 @@ static int rzg2l_cru_start_streaming_vq(struct vb2_queue 
*vq, unsigned int count
struct rzg2l_cru_dev *cru = vb2_get_drv_priv(vq);
int ret;
 
+   ret = pm_runtime_resume_and_get(cru->dev);
+   if (ret)
+   return ret;
+
+   ret = clk_prepare_enable(cru->vclk);
+   if (ret)
+   goto err_pm_put;
+
/* Release reset state */
ret = reset_control_deassert(cru->aresetn);
if (ret) {
dev_err(cru->dev, "failed to deassert aresetn\n");
-   return ret;
+   goto err_vclk_disable;
}
 
ret = reset_control_deassert(cru->presetn);
if (ret) {
reset_control_assert(cru->aresetn);
dev_err(cru->dev, "failed to deassert presetn\n");
-   return ret;
+   goto assert_aresetn;
}
 
ret = request_irq(cru->image_conv_irq, rzg2l_cru_irq,
  IRQF_SHARED, KBUILD_MODNAME, cru);
if (ret) {
dev_err(cru->dev, "failed to request irq\n");
-   goto assert_resets;
+   goto assert_presetn;
}
 
/* Allocate scratch buffer. */
@@ -686,10 +673,18 @@ out:
 free_image_conv_irq:
free_irq(cru->image_conv_irq, cru);
 
-assert_resets:
+assert_presetn:
reset_control_assert(cru->presetn);
+
+assert_aresetn:
reset_control_assert(cru->aresetn);
 
+err_vclk_disable:
+   clk_disable_unprepare(cru->vclk);
+
+err_pm_put:
+   pm_runtime_put_sync(cru->dev);
+
return ret;
 }
 
@@ -704,9 +699,11 @@ static void rzg2l_cru_stop_streaming_vq(struct vb2_queue 
*vq)
  cru->scratch, cru->scratch_phys);
 
free_irq(cru->image_conv_irq, cru);
-   reset_control_assert(cru->presetn);
-
return_unused_buffers(cru, VB2_BUF_STATE_ERROR);
+
+   reset_control_assert(cru->presetn);
+   clk_disable_unprepare(cru->vclk);
+   pm_runtime_put_sync(cru->dev);
 }
 
 static const struct vb2_ops rzg2l_cru_qops = {


[git:media_stage/master] media: platform: rzg2l-cru: rzg2l-video: Fix image processing initialization

2024-02-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: platform: rzg2l-cru: rzg2l-video: Fix image processing 
initialization
Author:  Biju Das 
Date:Tue Feb 13 18:12:31 2024 +

As per section 35.3.1 Starting Reception for the MIPI CSI-2 Input on the
latest hardware manual (R01UH0914EJ0140 Rev.1.40) it is mentioned that
initialize the AXI master first and then initialize the image processing.
Fix the start procedure as per the hardware manual.

Signed-off-by: Biju Das 
Reviewed-by: Laurent Pinchart 
Link: 
https://lore.kernel.org/r/20240213181233.242316-4-biju.das...@bp.renesas.com
Signed-off-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

---

diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c 
b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index d0ffa90bc656..a7d6fe831d54 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -430,13 +430,6 @@ int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev 
*cru)
 
spin_lock_irqsave(>qlock, flags);
 
-   /* Initialize image convert */
-   ret = rzg2l_cru_initialize_image_conv(cru, fmt);
-   if (ret) {
-   spin_unlock_irqrestore(>qlock, flags);
-   return ret;
-   }
-
/* Select a video input */
rzg2l_cru_write(cru, CRUnCTRL, CRUnCTRL_VINSEL(0));
 
@@ -450,6 +443,13 @@ int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev 
*cru)
/* Initialize the AXI master */
rzg2l_cru_initialize_axi(cru);
 
+   /* Initialize image convert */
+   ret = rzg2l_cru_initialize_image_conv(cru, fmt);
+   if (ret) {
+   spin_unlock_irqrestore(>qlock, flags);
+   return ret;
+   }
+
/* Enable interrupt */
rzg2l_cru_write(cru, CRUnIE, CRUnIE_EFE);
 


[git:media_stage/master] media: platform: rzg2l-cru: rzg2l-csi2: Restructure vclk handling

2024-02-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: platform: rzg2l-cru: rzg2l-csi2: Restructure vclk handling
Author:  Biju Das 
Date:Tue Feb 13 18:12:32 2024 +

As per section 35.3.1 Starting Reception for the MIPI CSI-2 Input on the
latest hardware manual (R01UH0914EJ0145 Rev.1.45) we need to disable the
vclk before enabling the LINK reception and enable the vclk after enabling
the link Reception. So restructure vclk handling as per the HW manual.

Signed-off-by: Biju Das 
Link: 
https://lore.kernel.org/r/20240213181233.242316-5-biju.das...@bp.renesas.com
Reviewed-by: Laurent Pinchart 
Signed-off-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 .../media/platform/renesas/rzg2l-cru/rzg2l-cru.h   |  3 ---
 .../media/platform/renesas/rzg2l-cru/rzg2l-csi2.c  | 28 +-
 .../media/platform/renesas/rzg2l-cru/rzg2l-ip.c| 15 ++--
 .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 10 
 4 files changed, 19 insertions(+), 37 deletions(-)

---

diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h 
b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
index 811603f18af0..a5a99b004322 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
@@ -133,9 +133,6 @@ struct rzg2l_cru_dev {
struct v4l2_pix_format format;
 };
 
-void rzg2l_cru_vclk_unprepare(struct rzg2l_cru_dev *cru);
-int rzg2l_cru_vclk_prepare(struct rzg2l_cru_dev *cru);
-
 int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev *cru);
 void rzg2l_cru_stop_image_processing(struct rzg2l_cru_dev *cru);
 
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c 
b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
index e00d9379dd2c..e68fcdaea207 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
@@ -108,6 +108,7 @@ struct rzg2l_csi2 {
struct reset_control *presetn;
struct reset_control *cmn_rstb;
struct clk *sysclk;
+   struct clk *vclk;
unsigned long vclk_rate;
 
struct v4l2_subdev subdev;
@@ -361,7 +362,7 @@ static int rzg2l_csi2_dphy_setting(struct v4l2_subdev *sd, 
bool on)
return rzg2l_csi2_dphy_disable(csi2);
 }
 
-static void rzg2l_csi2_mipi_link_enable(struct rzg2l_csi2 *csi2)
+static int rzg2l_csi2_mipi_link_enable(struct rzg2l_csi2 *csi2)
 {
unsigned long vclk_rate = csi2->vclk_rate / HZ_PER_MHZ;
u32 frrskw, frrclk, frrskw_coeff, frrclk_coeff;
@@ -386,11 +387,15 @@ static void rzg2l_csi2_mipi_link_enable(struct rzg2l_csi2 
*csi2)
rzg2l_csi2_write(csi2, CSI2nDTEL, 0xf778ff0f);
rzg2l_csi2_write(csi2, CSI2nDTEH, 0x001f);
 
+   clk_disable_unprepare(csi2->vclk);
+
/* Enable LINK reception */
rzg2l_csi2_write(csi2, CSI2nMCT3, CSI2nMCT3_RXEN);
+
+   return clk_prepare_enable(csi2->vclk);
 }
 
-static void rzg2l_csi2_mipi_link_disable(struct rzg2l_csi2 *csi2)
+static int rzg2l_csi2_mipi_link_disable(struct rzg2l_csi2 *csi2)
 {
unsigned int timeout = VSRSTS_RETRIES;
 
@@ -409,18 +414,21 @@ static void rzg2l_csi2_mipi_link_disable(struct 
rzg2l_csi2 *csi2)
 
if (!timeout)
dev_err(csi2->dev, "Clearing CSI2nRTST.VSRSTS timed out\n");
+
+   return 0;
 }
 
 static int rzg2l_csi2_mipi_link_setting(struct v4l2_subdev *sd, bool on)
 {
struct rzg2l_csi2 *csi2 = sd_to_csi2(sd);
+   int ret;
 
if (on)
-   rzg2l_csi2_mipi_link_enable(csi2);
+   ret = rzg2l_csi2_mipi_link_enable(csi2);
else
-   rzg2l_csi2_mipi_link_disable(csi2);
+   ret = rzg2l_csi2_mipi_link_disable(csi2);
 
-   return 0;
+   return ret;
 }
 
 static int rzg2l_csi2_s_stream(struct v4l2_subdev *sd, int enable)
@@ -731,7 +739,6 @@ static const struct media_entity_operations 
rzg2l_csi2_entity_ops = {
 static int rzg2l_csi2_probe(struct platform_device *pdev)
 {
struct rzg2l_csi2 *csi2;
-   struct clk *vclk;
int ret;
 
csi2 = devm_kzalloc(>dev, sizeof(*csi2), GFP_KERNEL);
@@ -757,12 +764,11 @@ static int rzg2l_csi2_probe(struct platform_device *pdev)
return dev_err_probe(>dev, PTR_ERR(csi2->sysclk),
 "Failed to get system clk\n");
 
-   vclk = clk_get(>dev, "video");
-   if (IS_ERR(vclk))
-   return dev_err_probe(>dev, PTR_ERR(vclk),
+   csi2->vclk = devm_clk_get(>dev, "video");
+   if (IS_ERR(csi2->vclk))
+   return dev_err_probe(>dev, PTR_ERR(csi2->vclk),
 "Failed to get video clock\n");
-   csi2->vclk_rate = clk_get_rate(vclk);
-   clk_put(vclk);
+   csi2->vclk_rate = clk_get_rate(csi2->vclk);
 
csi2->dev = &g

[git:media_stage/master] Revert "media: ov08x40: Reduce start streaming time"

2024-02-06 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: Revert "media: ov08x40: Reduce start streaming time"
Author:  Sakari Ailus 
Date:Sun Feb 4 23:50:12 2024 +0200

This reverts commit feb8831be9d468ee961289c6a275536a1ee0011c.

Commit feb8831be9d468ee961289c6a275536a1ee0011c contained unintentional
changes to Documentation/devicetree/bindings/media/video-interfaces.yaml
and arch/arm/boot/dts/ti/omap/omap3-n9.dts. Revert the entire patch.

Signed-off-by: Sakari Ailus 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 .../bindings/media/video-interfaces.yaml   |2 +-
 arch/arm/boot/dts/ti/omap/omap3-n9.dts |2 +-
 drivers/media/i2c/ov08x40.c| 1209 +++-
 3 files changed, 1154 insertions(+), 59 deletions(-)

---

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.yaml 
b/Documentation/devicetree/bindings/media/video-interfaces.yaml
index ea511f2fed98..26e3e7d7c67b 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.yaml
+++ b/Documentation/devicetree/bindings/media/video-interfaces.yaml
@@ -190,7 +190,7 @@ properties:
   Allow MIPI CSI-2 non-continuous clock mode.
 
   link-frequencies:
-$ref: /schemas/types.yaml#/definitions/uint32-array
+$ref: /schemas/types.yaml#/definitions/uint64-array
 description:
   Allowed data bus frequencies. For MIPI CSI-2, for instance, this is the
   actual frequency of the bus, not bits per clock per lane value. An array
diff --git a/arch/arm/boot/dts/ti/omap/omap3-n9.dts 
b/arch/arm/boot/dts/ti/omap/omap3-n9.dts
index 728a8fcf25b3..a3cf3f443785 100644
--- a/arch/arm/boot/dts/ti/omap/omap3-n9.dts
+++ b/arch/arm/boot/dts/ti/omap/omap3-n9.dts
@@ -26,7 +26,7 @@
flash-leds = <_flash _indicator>;
port {
smia_1_1: endpoint {
-   link-frequencies = /bits/ 32 <19920 
21000 49920>;
+   link-frequencies = /bits/ 64 <19920 
21000 49920>;
clock-lanes = <0>;
data-lanes = <1 2>;
remote-endpoint = <_ep>;
diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index 48df077522ad..010a6017e1ad 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -1,7 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (c) 2022 Intel Corporation.
 
-#include 
 #include 
 #include 
 #include 
@@ -96,12 +95,6 @@
 /* Vertical Window Offset */
 #define OV08X40_REG_V_WIN_OFFSET   0x3813
 
-/* Burst Register */
-#define OV08X40_REG_XTALK_FIRST_A  0x5a80
-#define OV08X40_REG_XTALK_LAST_A   0x5b9f
-#define OV08X40_REG_XTALK_FIRST_B  0x5bc0
-#define OV08X40_REG_XTALK_LAST_B   0x5f1f
-
 enum {
OV08X40_LINK_FREQ_400MHZ_INDEX,
 };
@@ -677,6 +670,1158 @@ static const struct ov08x40_reg mode_3856x2416_regs[] = {
{0x3502, 0x10},
{0x3508, 0x0f},
{0x3509, 0x80},
+   {0x5a80, 0x75},
+   {0x5a81, 0x75},
+   {0x5a82, 0x75},
+   {0x5a83, 0x75},
+   {0x5a84, 0x75},
+   {0x5a85, 0x75},
+   {0x5a86, 0x75},
+   {0x5a87, 0x75},
+   {0x5a88, 0x75},
+   {0x5a89, 0x75},
+   {0x5a8a, 0x75},
+   {0x5a8b, 0x75},
+   {0x5a8c, 0x75},
+   {0x5a8d, 0x75},
+   {0x5a8e, 0x75},
+   {0x5a8f, 0x75},
+   {0x5a90, 0x75},
+   {0x5a91, 0x75},
+   {0x5a92, 0x75},
+   {0x5a93, 0x75},
+   {0x5a94, 0x75},
+   {0x5a95, 0x75},
+   {0x5a96, 0x75},
+   {0x5a97, 0x75},
+   {0x5a98, 0x75},
+   {0x5a99, 0x75},
+   {0x5a9a, 0x75},
+   {0x5a9b, 0x75},
+   {0x5a9c, 0x75},
+   {0x5a9d, 0x75},
+   {0x5a9e, 0x75},
+   {0x5a9f, 0x75},
+   {0x5aa0, 0x75},
+   {0x5aa1, 0x75},
+   {0x5aa2, 0x75},
+   {0x5aa3, 0x75},
+   {0x5aa4, 0x75},
+   {0x5aa5, 0x75},
+   {0x5aa6, 0x75},
+   {0x5aa7, 0x75},
+   {0x5aa8, 0x75},
+   {0x5aa9, 0x75},
+   {0x5aaa, 0x75},
+   {0x5aab, 0x75},
+   {0x5aac, 0x75},
+   {0x5aad, 0x75},
+   {0x5aae, 0x75},
+   {0x5aaf, 0x75},
+   {0x5ab0, 0x75},
+   {0x5ab1, 0x75},
+   {0x5ab2, 0x75},
+   {0x5ab3, 0x75},
+   {0x5ab4, 0x75},
+   {0x5ab5, 0x75},
+   {0x5ab6, 0x75},
+   {0x5ab7, 0x75},
+   {0x5ab8, 0x75},
+   {0x5ab9, 0x75},
+   {0x5aba, 0x75},
+   {0x5abb, 0x75},
+   {0x5abc, 0x75},
+   {0x5abd, 0x75},
+   {0x5abe, 0x75},
+   {0x5abf, 0x75},
+   {0x5ac0, 0x75},
+   {0x5ac1, 0x75},
+   {0x5ac2, 0x75},
+   {0x5ac3, 0x75},
+   {0x5ac4, 0x75},
+   {0x5ac5, 0x75},
+   {0x5ac6, 0x75},
+   {0x5ac7, 0x75},
+   {0x5ac8, 0x75},
+   {0x5ac9, 0x75},
+   {0x5aca, 0x75},
+   {0x5acb, 0x75},
+   {0x5acc, 

[git:media_stage/master] media: ov08x40: Reduce start streaming time

2024-02-06 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: ov08x40: Reduce start streaming time
Author:  Jason Chen 
Date:Wed Jan 24 15:43:01 2024 +0100

Because video duration involves calculating the streaming time, and i2c
communication incurs too many XTALK register settings every 4 bytes with
i2c START and STOP.

So we have opted switch to the i2c burst method.
This method involves writing the XTALK registers in the order of
the register block.

The start streaming time can be reduced from around 400ms to 150ms

[Sakari Ailus: Drop unneeded dev_dbg().]

Signed-off-by: Jason Chen 
Reviewed-by: Sergey Senozhatsky 
Signed-off-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/ov08x40.c | 1209 ++-
 1 file changed, 57 insertions(+), 1152 deletions(-)

---

diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index 010a6017e1ad..48df077522ad 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (c) 2022 Intel Corporation.
 
+#include 
 #include 
 #include 
 #include 
@@ -95,6 +96,12 @@
 /* Vertical Window Offset */
 #define OV08X40_REG_V_WIN_OFFSET   0x3813
 
+/* Burst Register */
+#define OV08X40_REG_XTALK_FIRST_A  0x5a80
+#define OV08X40_REG_XTALK_LAST_A   0x5b9f
+#define OV08X40_REG_XTALK_FIRST_B  0x5bc0
+#define OV08X40_REG_XTALK_LAST_B   0x5f1f
+
 enum {
OV08X40_LINK_FREQ_400MHZ_INDEX,
 };
@@ -670,1158 +677,6 @@ static const struct ov08x40_reg mode_3856x2416_regs[] = {
{0x3502, 0x10},
{0x3508, 0x0f},
{0x3509, 0x80},
-   {0x5a80, 0x75},
-   {0x5a81, 0x75},
-   {0x5a82, 0x75},
-   {0x5a83, 0x75},
-   {0x5a84, 0x75},
-   {0x5a85, 0x75},
-   {0x5a86, 0x75},
-   {0x5a87, 0x75},
-   {0x5a88, 0x75},
-   {0x5a89, 0x75},
-   {0x5a8a, 0x75},
-   {0x5a8b, 0x75},
-   {0x5a8c, 0x75},
-   {0x5a8d, 0x75},
-   {0x5a8e, 0x75},
-   {0x5a8f, 0x75},
-   {0x5a90, 0x75},
-   {0x5a91, 0x75},
-   {0x5a92, 0x75},
-   {0x5a93, 0x75},
-   {0x5a94, 0x75},
-   {0x5a95, 0x75},
-   {0x5a96, 0x75},
-   {0x5a97, 0x75},
-   {0x5a98, 0x75},
-   {0x5a99, 0x75},
-   {0x5a9a, 0x75},
-   {0x5a9b, 0x75},
-   {0x5a9c, 0x75},
-   {0x5a9d, 0x75},
-   {0x5a9e, 0x75},
-   {0x5a9f, 0x75},
-   {0x5aa0, 0x75},
-   {0x5aa1, 0x75},
-   {0x5aa2, 0x75},
-   {0x5aa3, 0x75},
-   {0x5aa4, 0x75},
-   {0x5aa5, 0x75},
-   {0x5aa6, 0x75},
-   {0x5aa7, 0x75},
-   {0x5aa8, 0x75},
-   {0x5aa9, 0x75},
-   {0x5aaa, 0x75},
-   {0x5aab, 0x75},
-   {0x5aac, 0x75},
-   {0x5aad, 0x75},
-   {0x5aae, 0x75},
-   {0x5aaf, 0x75},
-   {0x5ab0, 0x75},
-   {0x5ab1, 0x75},
-   {0x5ab2, 0x75},
-   {0x5ab3, 0x75},
-   {0x5ab4, 0x75},
-   {0x5ab5, 0x75},
-   {0x5ab6, 0x75},
-   {0x5ab7, 0x75},
-   {0x5ab8, 0x75},
-   {0x5ab9, 0x75},
-   {0x5aba, 0x75},
-   {0x5abb, 0x75},
-   {0x5abc, 0x75},
-   {0x5abd, 0x75},
-   {0x5abe, 0x75},
-   {0x5abf, 0x75},
-   {0x5ac0, 0x75},
-   {0x5ac1, 0x75},
-   {0x5ac2, 0x75},
-   {0x5ac3, 0x75},
-   {0x5ac4, 0x75},
-   {0x5ac5, 0x75},
-   {0x5ac6, 0x75},
-   {0x5ac7, 0x75},
-   {0x5ac8, 0x75},
-   {0x5ac9, 0x75},
-   {0x5aca, 0x75},
-   {0x5acb, 0x75},
-   {0x5acc, 0x75},
-   {0x5acd, 0x75},
-   {0x5ace, 0x75},
-   {0x5acf, 0x75},
-   {0x5ad0, 0x75},
-   {0x5ad1, 0x75},
-   {0x5ad2, 0x75},
-   {0x5ad3, 0x75},
-   {0x5ad4, 0x75},
-   {0x5ad5, 0x75},
-   {0x5ad6, 0x75},
-   {0x5ad7, 0x75},
-   {0x5ad8, 0x75},
-   {0x5ad9, 0x75},
-   {0x5ada, 0x75},
-   {0x5adb, 0x75},
-   {0x5adc, 0x75},
-   {0x5add, 0x75},
-   {0x5ade, 0x75},
-   {0x5adf, 0x75},
-   {0x5ae0, 0x75},
-   {0x5ae1, 0x75},
-   {0x5ae2, 0x75},
-   {0x5ae3, 0x75},
-   {0x5ae4, 0x75},
-   {0x5ae5, 0x75},
-   {0x5ae6, 0x75},
-   {0x5ae7, 0x75},
-   {0x5ae8, 0x75},
-   {0x5ae9, 0x75},
-   {0x5aea, 0x75},
-   {0x5aeb, 0x75},
-   {0x5aec, 0x75},
-   {0x5aed, 0x75},
-   {0x5aee, 0x75},
-   {0x5aef, 0x75},
-   {0x5af0, 0x75},
-   {0x5af1, 0x75},
-   {0x5af2, 0x75},
-   {0x5af3, 0x75},
-   {0x5af4, 0x75},
-   {0x5af5, 0x75},
-   {0x5af6, 0x75},
-   {0x5af7, 0x75},
-   {0x5af8, 0x75},
-   {0x5af9, 0x75},
-   {0x5afa, 0x75},
-   {0x5afb, 0x75},
-   {0x5afc, 0x75},
-   {0x5afd, 0x75},
-   {0x5afe, 0x75},
-   {0x5aff, 0x75},
-   {0x5b00, 0x75},
-   {0x5b01, 0x75},
-   {0x5b02, 0x75},
-   {0x5b03, 0x75},
-   {0x5b04, 0x75},
-   {0x5b05, 0x75},
-   {0x5b06, 0x75},
-   {0x5b07, 0x75},
-   {0x5b08, 0x75

[git:media_stage/master] media: mc: Add local pad to pipeline regardless of the link state

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mc: Add local pad to pipeline regardless of the link state
Author:  Laurent Pinchart 
Date:Sun Jan 14 15:55:40 2024 +0200

When building pipelines by following links, the
media_pipeline_explore_next_link() function only traverses enabled
links. The remote pad of a disabled link is not added to the pipeline,
and neither is the local pad. While the former is correct as disabled
links should not be followed, not adding the local pad breaks processing
of the MEDIA_PAD_FL_MUST_CONNECT flag.

The MEDIA_PAD_FL_MUST_CONNECT flag is checked in the
__media_pipeline_start() function that iterates over all pads after
populating the pipeline. If the pad is not present, the check gets
skipped, rendering it useless.

Fix this by adding the local pad of all links regardless of their state,
only skipping the remote pad for disabled links.

Cc: sta...@vger.kernel.org # 6.1
Fixes: ae219872834a ("media: mc: entity: Rewrite media_pipeline_start()")
Reported-by: Frieder Schrempf 
Closes: 
https://lore.kernel.org/linux-media/7658a15a-80c5-219f-2477-2a94ba6c6...@kontron.de
Signed-off-by: Laurent Pinchart 
Acked-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/mc/mc-entity.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

---

diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index 543a392f8635..a6f28366106f 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -620,13 +620,6 @@ static int media_pipeline_explore_next_link(struct 
media_pipeline *pipe,
link->source->entity->name, link->source->index,
link->sink->entity->name, link->sink->index);
 
-   /* Skip links that are not enabled. */
-   if (!(link->flags & MEDIA_LNK_FL_ENABLED)) {
-   dev_dbg(walk->mdev->dev,
-   "media pipeline: skipping link (disabled)\n");
-   return 0;
-   }
-
/* Get the local pad and remote pad. */
if (link->source->entity == pad->entity) {
local = link->source;
@@ -648,13 +641,20 @@ static int media_pipeline_explore_next_link(struct 
media_pipeline *pipe,
}
 
/*
-* Add the local and remote pads of the link to the pipeline and push
-* them to the stack, if they're not already present.
+* Add the local pad of the link to the pipeline and push it to the
+* stack, if not already present.
 */
ret = media_pipeline_add_pad(pipe, walk, local);
if (ret)
return ret;
 
+   /* Similarly, add the remote pad, but only if the link is enabled. */
+   if (!(link->flags & MEDIA_LNK_FL_ENABLED)) {
+   dev_dbg(walk->mdev->dev,
+   "media pipeline: skipping link (disabled)\n");
+   return 0;
+   }
+
ret = media_pipeline_add_pad(pipe, walk, remote);
if (ret)
return ret;


[git:media_stage/master] media: mc: Add num_links flag to media_pad

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mc: Add num_links flag to media_pad
Author:  Laurent Pinchart 
Date:Mon Jan 15 00:30:02 2024 +0200

Maintain a counter of the links connected to a pad in the media_pad
structure. This helps checking if a pad is connected to anything, which
will be used in the pipeline building code.

Cc: sta...@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart 
Acked-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/mc/mc-entity.c | 6 ++
 include/media/media-entity.h | 2 ++
 2 files changed, 8 insertions(+)

---

diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index 7839e3f68efa..c2d8f59b62c1 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -1038,6 +1038,9 @@ static void __media_entity_remove_link(struct 
media_entity *entity,
 
/* Remove the reverse links for a data link. */
if ((link->flags & MEDIA_LNK_FL_LINK_TYPE) == MEDIA_LNK_FL_DATA_LINK) {
+   link->source->num_links--;
+   link->sink->num_links--;
+
if (link->source->entity == entity)
remote = link->sink->entity;
else
@@ -1143,6 +1146,9 @@ media_create_pad_link(struct media_entity *source, u16 
source_pad,
sink->num_links++;
source->num_links++;
 
+   link->source->num_links++;
+   link->sink->num_links++;
+
return 0;
 }
 EXPORT_SYMBOL_GPL(media_create_pad_link);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index c79176ed6299..0393b23129eb 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -225,6 +225,7 @@ enum media_pad_signal_type {
  * @graph_obj: Embedded structure containing the media object common data
  * @entity:Entity this pad belongs to
  * @index: Pad index in the entity pads array, numbered from 0 to n
+ * @num_links: Number of links connected to this pad
  * @sig_type:  Type of the signal inside a media pad
  * @flags: Pad flags, as defined in
  * :ref:`include/uapi/linux/media.h `
@@ -236,6 +237,7 @@ struct media_pad {
struct media_gobj graph_obj;/* must be first field in struct */
struct media_entity *entity;
u16 index;
+   u16 num_links;
enum media_pad_signal_type sig_type;
unsigned long flags;
 


[git:media_stage/master] media: nxp: imx8-isi: Check whether crossbar pad is non-NULL before access

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: nxp: imx8-isi: Check whether crossbar pad is non-NULL before 
access
Author:  Marek Vasut 
Date:Fri Dec 1 16:06:04 2023 +0100

When translating source to sink streams in the crossbar subdev, the
driver tries to locate the remote subdev connected to the sink pad. The
remote pad may be NULL, if userspace tries to enable a stream that ends
at an unconnected crossbar sink. When that occurs, the driver
dereferences the NULL pad, leading to a crash.

Prevent the crash by checking if the pad is NULL before using it, and
return an error if it is.

Cc: sta...@vger.kernel.org # 6.1
Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver")
Signed-off-by: Marek Vasut 
Reviewed-by: Kieran Bingham 
Reviewed-by: Fabio Estevam 
Reviewed-by: Laurent Pinchart 
Link: https://lore.kernel.org/r/20231201150614.63300-1-ma...@denx.de
Signed-off-by: Laurent Pinchart 
Acked-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

---

diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c 
b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
index 575f17337388..1bb1334ec6f2 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
@@ -160,8 +160,14 @@ mxc_isi_crossbar_xlate_streams(struct mxc_isi_crossbar 
*xbar,
}
 
pad = media_pad_remote_pad_first(>pads[sink_pad]);
-   sd = media_entity_to_v4l2_subdev(pad->entity);
+   if (!pad) {
+   dev_dbg(xbar->isi->dev,
+   "no pad connected to crossbar input %u\n",
+   sink_pad);
+   return ERR_PTR(-EPIPE);
+   }
 
+   sd = media_entity_to_v4l2_subdev(pad->entity);
if (!sd) {
dev_dbg(xbar->isi->dev,
"no entity connected to crossbar input %u\n",


[git:media_stage/master] media: mc: Fix flags handling when creating pad links

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mc: Fix flags handling when creating pad links
Author:  Laurent Pinchart 
Date:Mon Jan 15 00:24:12 2024 +0200

The media_create_pad_link() function doesn't correctly clear reject link
type flags, nor does it set the DATA_LINK flag. It only works because
the MEDIA_LNK_FL_DATA_LINK flag's value is 0.

Fix it by returning an error if any link type flag is set. This doesn't
introduce any regression, as nobody calls the media_create_pad_link()
function with link type flags (easily checked by grepping for the flag
in the source code, there are very few hits).

Set the MEDIA_LNK_FL_DATA_LINK explicitly, which is a no-op that the
compiler will optimize out, but is still useful to make the code more
explicit and easier to understand.

Cc: sta...@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart 
Acked-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/mc/mc-entity.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

---

diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index a6f28366106f..7839e3f68efa 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -1092,6 +1092,11 @@ media_create_pad_link(struct media_entity *source, u16 
source_pad,
struct media_link *link;
struct media_link *backlink;
 
+   if (flags & MEDIA_LNK_FL_LINK_TYPE)
+   return -EINVAL;
+
+   flags |= MEDIA_LNK_FL_DATA_LINK;
+
if (WARN_ON(!source || !sink) ||
WARN_ON(source_pad >= source->num_pads) ||
WARN_ON(sink_pad >= sink->num_pads))
@@ -1107,7 +1112,7 @@ media_create_pad_link(struct media_entity *source, u16 
source_pad,
 
link->source = >pads[source_pad];
link->sink = >pads[sink_pad];
-   link->flags = flags & ~MEDIA_LNK_FL_INTERFACE_LINK;
+   link->flags = flags;
 
/* Initialize graph object embedded at the new link */
media_gobj_create(source->graph_obj.mdev, MEDIA_GRAPH_LINK,


[git:media_stage/master] media: mc: Rename pad variable to clarify intent

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mc: Rename pad variable to clarify intent
Author:  Laurent Pinchart 
Date:Mon Jan 15 00:30:02 2024 +0200

The pad local variable in the media_pipeline_explore_next_link()
function is used to store the pad through which the entity has been
reached. Rename it to origin to reflect that and make the code easier to
read. This will be even more important in subsequent commits when
expanding the function with additional logic.

Cc: sta...@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart 
Acked-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/mc/mc-entity.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

---

diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index c2d8f59b62c1..5907925ffd89 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -605,13 +605,13 @@ static int media_pipeline_explore_next_link(struct 
media_pipeline *pipe,
struct media_pipeline_walk *walk)
 {
struct media_pipeline_walk_entry *entry = media_pipeline_walk_top(walk);
-   struct media_pad *pad;
+   struct media_pad *origin;
struct media_link *link;
struct media_pad *local;
struct media_pad *remote;
int ret;
 
-   pad = entry->pad;
+   origin = entry->pad;
link = list_entry(entry->links, typeof(*link), list);
media_pipeline_walk_pop(walk);
 
@@ -621,7 +621,7 @@ static int media_pipeline_explore_next_link(struct 
media_pipeline *pipe,
link->sink->entity->name, link->sink->index);
 
/* Get the local pad and remote pad. */
-   if (link->source->entity == pad->entity) {
+   if (link->source->entity == origin->entity) {
local = link->source;
remote = link->sink;
} else {
@@ -633,8 +633,9 @@ static int media_pipeline_explore_next_link(struct 
media_pipeline *pipe,
 * Skip links that originate from a different pad than the incoming pad
 * that is not connected internally in the entity to the incoming pad.
 */
-   if (pad != local &&
-   !media_entity_has_pad_interdep(pad->entity, pad->index, 
local->index)) {
+   if (origin != local &&
+   !media_entity_has_pad_interdep(origin->entity, origin->index,
+  local->index)) {
dev_dbg(walk->mdev->dev,
"media pipeline: skipping link (no route)\n");
return 0;


[git:media_stage/master] media: nxp: imx8-isi: Mark all crossbar sink pads as MUST_CONNECT

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: nxp: imx8-isi: Mark all crossbar sink pads as MUST_CONNECT
Author:  Laurent Pinchart 
Date:Mon Jan 15 04:16:29 2024 +0200

All the sink pads of the crossbar switch require an active link if
they're part of the pipeline. Mark them with the
MEDIA_PAD_FL_MUST_CONNECT flag to fail pipeline validation if they're
not connected. This allows removing a manual check when translating
streams.

Cc: sta...@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart 
Acked-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

---

diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c 
b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
index 1bb1334ec6f2..93a55c97cd17 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
@@ -160,13 +160,6 @@ mxc_isi_crossbar_xlate_streams(struct mxc_isi_crossbar 
*xbar,
}
 
pad = media_pad_remote_pad_first(>pads[sink_pad]);
-   if (!pad) {
-   dev_dbg(xbar->isi->dev,
-   "no pad connected to crossbar input %u\n",
-   sink_pad);
-   return ERR_PTR(-EPIPE);
-   }
-
sd = media_entity_to_v4l2_subdev(pad->entity);
if (!sd) {
dev_dbg(xbar->isi->dev,
@@ -475,7 +468,8 @@ int mxc_isi_crossbar_init(struct mxc_isi_dev *isi)
}
 
for (i = 0; i < xbar->num_sinks; ++i)
-   xbar->pads[i].flags = MEDIA_PAD_FL_SINK;
+   xbar->pads[i].flags = MEDIA_PAD_FL_SINK
+   | MEDIA_PAD_FL_MUST_CONNECT;
for (i = 0; i < xbar->num_sources; ++i)
xbar->pads[i + xbar->num_sinks].flags = MEDIA_PAD_FL_SOURCE;
 


[git:media_stage/master] media: nxp: imx8-isi: Factor out a variable

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: nxp: imx8-isi: Factor out a variable
Author:  Ricardo Ribalda 
Date:Sun Jan 28 16:13:56 2024 +

gcc-11 seems to believe that the coeffs variable can be used
uninitialized. Refactor the code and remove the cscen variable to
convince gcc that we are doing a good job.

drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c:218:20: warning: 'coeffs' may 
be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Laurent Pinchart 
Link: 
https://lore.kernel.org/r/20240128-gcc-11-warnings-v1-1-52bbdf492...@chromium.org
Signed-off-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

---

diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c 
b/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
index 19e80b95ffea..5623914f95e6 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
@@ -215,8 +215,7 @@ static void mxc_isi_channel_set_csc(struct mxc_isi_pipe 
*pipe,
[MXC_ISI_ENC_RGB] = "RGB",
[MXC_ISI_ENC_YUV] = "YUV",
};
-   const u32 *coeffs;
-   bool cscen = true;
+   const u32 *coeffs = NULL;
u32 val;
 
val = mxc_isi_read(pipe, CHNL_IMG_CTRL);
@@ -235,14 +234,13 @@ static void mxc_isi_channel_set_csc(struct mxc_isi_pipe 
*pipe,
val |= CHNL_IMG_CTRL_CSC_MODE(CHNL_IMG_CTRL_CSC_MODE_RGB2YCBCR);
} else {
/* Bypass CSC */
-   cscen = false;
val |= CHNL_IMG_CTRL_CSC_BYPASS;
}
 
dev_dbg(pipe->isi->dev, "CSC: %s -> %s\n",
encodings[in_encoding], encodings[out_encoding]);
 
-   if (cscen) {
+   if (coeffs) {
mxc_isi_write(pipe, CHNL_CSC_COEFF0, coeffs[0]);
mxc_isi_write(pipe, CHNL_CSC_COEFF1, coeffs[1]);
mxc_isi_write(pipe, CHNL_CSC_COEFF2, coeffs[2]);
@@ -253,7 +251,7 @@ static void mxc_isi_channel_set_csc(struct mxc_isi_pipe 
*pipe,
 
mxc_isi_write(pipe, CHNL_IMG_CTRL, val);
 
-   *bypass = !cscen;
+   *bypass = !coeffs;
 }
 
 void mxc_isi_channel_set_alpha(struct mxc_isi_pipe *pipe, u8 alpha)


[git:media_stage/master] media: mc: Expand MUST_CONNECT flag to always require an enabled link

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mc: Expand MUST_CONNECT flag to always require an enabled link
Author:  Laurent Pinchart 
Date:Mon Jan 15 01:04:52 2024 +0200

The MEDIA_PAD_FL_MUST_CONNECT flag indicates that the pad requires an
enabled link to stream, but only if it has any link at all. This makes
little sense, as if a pad is part of a pipeline, there are very few use
cases for an active link to be mandatory only if links exist at all. A
review of in-tree drivers confirms they all need an enabled link for
pads marked with the MEDIA_PAD_FL_MUST_CONNECT flag.

Expand the scope of the flag by rejecting pads that have no links at
all. This requires modifying the pipeline build code to add those pads
to the pipeline.

Cc: sta...@vger.kernel.org # 6.1
Signed-off-by: Laurent Pinchart 
Acked-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 .../userspace-api/media/mediactl/media-types.rst   | 11 ++---
 drivers/media/mc/mc-entity.c   | 53 ++
 2 files changed, 48 insertions(+), 16 deletions(-)

---

diff --git a/Documentation/userspace-api/media/mediactl/media-types.rst 
b/Documentation/userspace-api/media/mediactl/media-types.rst
index 0ffeece1e0c8..6332e8395263 100644
--- a/Documentation/userspace-api/media/mediactl/media-types.rst
+++ b/Documentation/userspace-api/media/mediactl/media-types.rst
@@ -375,12 +375,11 @@ Types and flags used to represent the media graph elements
  are origins of links.
 
 *  -  ``MEDIA_PAD_FL_MUST_CONNECT``
-   -  If this flag is set and the pad is linked to any other pad, then
- at least one of those links must be enabled for the entity to be
- able to stream. There could be temporary reasons (e.g. device
- configuration dependent) for the pad to need enabled links even
- when this flag isn't set; the absence of the flag doesn't imply
- there is none.
+   -  If this flag is set, then for this pad to be able to stream, it must
+ be connected by at least one enabled link. There could be temporary
+ reasons (e.g. device configuration dependent) for the pad to need
+ enabled links even when this flag isn't set; the absence of the flag
+ doesn't imply there is none.
 
 
 One and only one of ``MEDIA_PAD_FL_SINK`` and ``MEDIA_PAD_FL_SOURCE``
diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index 5907925ffd89..0e28b9a7936e 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -535,14 +535,15 @@ static int media_pipeline_walk_push(struct 
media_pipeline_walk *walk,
 
 /*
  * Move the top entry link cursor to the next link. If all links of the entry
- * have been visited, pop the entry itself.
+ * have been visited, pop the entry itself. Return true if the entry has been
+ * popped.
  */
-static void media_pipeline_walk_pop(struct media_pipeline_walk *walk)
+static bool media_pipeline_walk_pop(struct media_pipeline_walk *walk)
 {
struct media_pipeline_walk_entry *entry;
 
if (WARN_ON(walk->stack.top < 0))
-   return;
+   return false;
 
entry = media_pipeline_walk_top(walk);
 
@@ -552,7 +553,7 @@ static void media_pipeline_walk_pop(struct 
media_pipeline_walk *walk)
walk->stack.top);
 
walk->stack.top--;
-   return;
+   return true;
}
 
entry->links = entry->links->next;
@@ -560,6 +561,8 @@ static void media_pipeline_walk_pop(struct 
media_pipeline_walk *walk)
dev_dbg(walk->mdev->dev,
"media pipeline: moved entry %u to next link\n",
walk->stack.top);
+
+   return false;
 }
 
 /* Free all memory allocated while walking the pipeline. */
@@ -609,11 +612,12 @@ static int media_pipeline_explore_next_link(struct 
media_pipeline *pipe,
struct media_link *link;
struct media_pad *local;
struct media_pad *remote;
+   bool last_link;
int ret;
 
origin = entry->pad;
link = list_entry(entry->links, typeof(*link), list);
-   media_pipeline_walk_pop(walk);
+   last_link = media_pipeline_walk_pop(walk);
 
dev_dbg(walk->mdev->dev,
"media pipeline: exploring link '%s':%u -> '%s':%u\n",
@@ -638,7 +642,7 @@ static int media_pipeline_explore_next_link(struct 
media_pipeline *pipe,
   local->index)) {
dev_dbg(walk->mdev->dev,
"media pipeline: skipping link (no route)\n");
-   return 0;
+   goto done;
}
 
/*
@@ -653,13 +657,44 @@ static int media_pipeline_explore_next_link(struct 
media_pipeline *pipe,
if (!(link->flags & MEDIA_LNK_FL_ENABLED)) {
dev_dbg(walk->mdev->dev

[git:media_stage/master] media: pci: cx23885: check cx23885_vdev_init() return

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: pci: cx23885: check cx23885_vdev_init() return
Author:  Hans Verkuil 
Date:Thu Oct 19 08:58:49 2023 +0200

cx23885_vdev_init() can return a NULL pointer, but that pointer
is used in the next line without a check.

Add a NULL pointer check and go to the error unwind if it is NULL.

Signed-off-by: Hans Verkuil 
Reported-by: Sicong Huang 

 drivers/media/pci/cx23885/cx23885-video.c | 8 
 1 file changed, 8 insertions(+)

---

diff --git a/drivers/media/pci/cx23885/cx23885-video.c 
b/drivers/media/pci/cx23885/cx23885-video.c
index 42fdcf992e48..7d4a409c433e 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -1354,6 +1354,10 @@ int cx23885_video_register(struct cx23885_dev *dev)
/* register Video device */
dev->video_dev = cx23885_vdev_init(dev, dev->pci,
_video_template, "video");
+   if (!dev->video_dev) {
+   err = -ENOMEM;
+   goto fail_unreg;
+   }
dev->video_dev->queue = >vb2_vidq;
dev->video_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
  V4L2_CAP_AUDIO | V4L2_CAP_VIDEO_CAPTURE;
@@ -1382,6 +1386,10 @@ int cx23885_video_register(struct cx23885_dev *dev)
/* register VBI device */
dev->vbi_dev = cx23885_vdev_init(dev, dev->pci,
_vbi_template, "vbi");
+   if (!dev->vbi_dev) {
+   err = -ENOMEM;
+   goto fail_unreg;
+   }
dev->vbi_dev->queue = >vb2_vbiq;
dev->vbi_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
V4L2_CAP_AUDIO | V4L2_CAP_VBI_CAPTURE;


[git:media_stage/master] media: videodev2.h: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: videodev2.h: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:01 2024 +

Named nested unions need their prefix:
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#nested-structs-unions

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Tested-by: Randy Dunlap 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Hans Verkuil 

 include/uapi/linux/videodev2.h | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

---

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 68e7ac178cc2..a8015e5e7fa4 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1041,13 +1041,13 @@ struct v4l2_requestbuffers {
  * struct v4l2_plane - plane info for multi-planar buffers
  * @bytesused: number of bytes occupied by data in the plane (payload)
  * @length:size of this plane (NOT the payload) in bytes
- * @mem_offset:when memory in the associated struct 
v4l2_buffer is
+ * @m.mem_offset:  when memory in the associated struct v4l2_buffer is
  * V4L2_MEMORY_MMAP, equals the offset from the start of
  * the device memory for this plane (or is a "cookie" that
  * should be passed to mmap() called on the video node)
- * @userptr:   when memory is V4L2_MEMORY_USERPTR, a userspace pointer
+ * @m.userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
  * pointing to this plane
- * @fd:when memory is V4L2_MEMORY_DMABUF, a userspace 
file
+ * @m.fd:  when memory is V4L2_MEMORY_DMABUF, a userspace file
  * descriptor associated with this plane
  * @m: union of @mem_offset, @userptr and @fd
  * @data_offset:   offset in the plane to the start of data; usually 0,
@@ -1085,14 +1085,14 @@ struct v4l2_plane {
  * @sequence:  sequence count of this frame
  * @memory:enum v4l2_memory; the method, in which the actual video data is
  * passed
- * @offset:for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
+ * @m.offset:  for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
  * offset from the start of the device memory for this plane,
  * (or a "cookie" that should be passed to mmap() as offset)
- * @userptr:   for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
+ * @m.userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
  * a userspace pointer pointing to this buffer
- * @fd:for non-multiplanar buffers with memory == 
V4L2_MEMORY_DMABUF;
+ * @m.fd:  for non-multiplanar buffers with memory == 
V4L2_MEMORY_DMABUF;
  * a userspace file descriptor associated with this buffer
- * @planes:for multiplanar buffers; userspace pointer to the array of plane
+ * @m.planes:  for multiplanar buffers; userspace pointer to the array of plane
  * info structs for this buffer
  * @m: union of @offset, @userptr, @planes and @fd
  * @length:size in bytes of the buffer (NOT its payload) for single-plane
@@ -2423,15 +2423,15 @@ struct v4l2_meta_format {
 
 /**
  * struct v4l2_format - stream data format
- * @type:  enum v4l2_buf_type; type of the data stream
- * @pix:   definition of an image format
- * @pix_mp:definition of a multiplanar image format
- * @win:   definition of an overlaid image
- * @vbi:   raw VBI capture or output parameters
- * @sliced:sliced VBI capture or output parameters
- * @raw_data:  placeholder for future extensions and custom formats
- * @fmt:   union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, @meta
- * and @raw_data
+ * @type:  enum v4l2_buf_type; type of the data stream
+ * @fmt.pix:   definition of an image format
+ * @fmt.pix_mp:definition of a multiplanar image format
+ * @fmt.win:   definition of an overlaid image
+ * @fmt.vbi:   raw VBI capture or output parameters
+ * @fmt.sliced:sliced VBI capture or output parameters
+ * @fmt.raw_data:  placeholder for future extensions and custom formats
+ * @fmt:   union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr,
+ * @meta and @raw_data
  */
 struct v4l2_format {
__u32type;


[git:media_stage/master] media: em28xx: annotate unchecked call to media_device_register()

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: em28xx: annotate unchecked call to media_device_register()
Author:  Nikita Zhandarovich 
Date:Fri Jan 12 05:42:26 2024 -0800

Static analyzers generate alerts for an unchecked call to
`media_device_register()`. However, in this case, the device will work
reliably without the media controller API.

Add a comment above the call to prevent future unnecessary changes.

Suggested-by: Mauro Carvalho Chehab 
Fixes: 37ecc7b1278f ("[media] em28xx: add media controller support")
Signed-off-by: Nikita Zhandarovich 
Signed-off-by: Hans Verkuil 

 drivers/media/usb/em28xx/em28xx-cards.c | 4 
 1 file changed, 4 insertions(+)

---

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 4d037c92af7c..bae76023cf71 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -4094,6 +4094,10 @@ static int em28xx_usb_probe(struct usb_interface *intf,
 * topology will likely change after the load of the em28xx subdrivers.
 */
 #ifdef CONFIG_MEDIA_CONTROLLER
+   /*
+* No need to check the return value, the device will still be
+* usable without media controller API.
+*/
retval = media_device_register(dev->media_dev);
 #endif
 


[git:media_stage/master] media: adv7180: Fix cppcheck errors

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: adv7180: Fix cppcheck errors
Author:  Bhavin Sharma 
Date:Tue Jan 2 19:36:40 2024 +0530

ERROR: else should follow close brace '}'

Signed-off-by: Bhavin Sharma 
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/adv7180.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 409b9a37f018..4829cbe32419 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1057,11 +1057,11 @@ static int adv7182_init(struct adv7180_state *state)
  
ADV7180_REG_EXTENDED_OUTPUT_CONTROL,
  0x17);
}
-   }
-   else
+   } else {
adv7180_write(state,
  ADV7180_REG_EXTENDED_OUTPUT_CONTROL,
  0x07);
+   }
adv7180_write(state, ADV7180_REG_OUTPUT_CONTROL, 0x0c);
adv7180_write(state, ADV7180_REG_CTRL_2, 0x40);
}


[git:media_stage/master] media: cx231xx: controls are from another device, mark this

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: cx231xx: controls are from another device, mark this
Author:  Hans Verkuil 
Date:Wed Jan 17 12:44:03 2024 +0100

The last argument of v4l2_ctrl_add_handler() indicates whether the controls
you add are from a control handler owned by another driver (true) or from
the same driver (false). In this case the last argument was incorrectly set
to false. The controls come from the cx25840 subdev.

Signed-off-by: Hans Verkuil 

 drivers/media/usb/cx231xx/cx231xx-417.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 3b75d062e602..343a4433ed24 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1759,7 +1759,7 @@ int cx231xx_417_register(struct cx231xx *dev)
dev->mpeg_ctrl_handler.ops = _ops;
if (dev->sd_cx25840)
v4l2_ctrl_add_handler(>mpeg_ctrl_handler.hdl,
-   dev->sd_cx25840->ctrl_handler, NULL, false);
+   dev->sd_cx25840->ctrl_handler, NULL, true);
if (dev->mpeg_ctrl_handler.hdl.error) {
err = dev->mpeg_ctrl_handler.hdl.error;
dprintk(3, "%s: can't add cx25840 controls\n", dev->name);


[git:media_stage/master] media: xc4000: Fix atomicity violation in xc4000_get_frequency

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: xc4000: Fix atomicity violation in xc4000_get_frequency
Author:  Gui-Dong Han <2045gem...@gmail.com>
Date:Fri Dec 22 13:50:30 2023 +0800

In xc4000_get_frequency():
*freq = priv->freq_hz + priv->freq_offset;
The code accesses priv->freq_hz and priv->freq_offset without holding any
lock.

In xc4000_set_params():
// Code that updates priv->freq_hz and priv->freq_offset
...

xc4000_get_frequency() and xc4000_set_params() may execute concurrently,
risking inconsistent reads of priv->freq_hz and priv->freq_offset. Since
these related data may update during reading, it can result in incorrect
frequency calculation, leading to atomicity violations.

This possible bug is found by an experimental static analysis tool
developed by our team, BassCheck[1]. This tool analyzes the locking APIs
to extract function pairs that can be concurrently executed, and then
analyzes the instructions in the paired functions to identify possible
concurrency bugs including data races and atomicity violations. The above
possible bug is reported when our tool analyzes the source code of
Linux 6.2.

To address this issue, it is proposed to add a mutex lock pair in
xc4000_get_frequency() to ensure atomicity. With this patch applied, our
tool no longer reports the possible bug, with the kernel configuration
allyesconfig for x86_64. Due to the lack of associated hardware, we cannot
test the patch in runtime testing, and just verify it according to the
code logic.

[1] https://sites.google.com/view/basscheck/

Fixes: 4c07e32884ab ("[media] xc4000: Fix get_frequency()")
Cc: sta...@vger.kernel.org
Reported-by: BassCheck 
Signed-off-by: Gui-Dong Han <2045gem...@gmail.com>
Signed-off-by: Hans Verkuil 

 drivers/media/tuners/xc4000.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/tuners/xc4000.c b/drivers/media/tuners/xc4000.c
index 57ded9ff3f04..29bc63021c5a 100644
--- a/drivers/media/tuners/xc4000.c
+++ b/drivers/media/tuners/xc4000.c
@@ -1515,10 +1515,10 @@ static int xc4000_get_frequency(struct dvb_frontend 
*fe, u32 *freq)
 {
struct xc4000_priv *priv = fe->tuner_priv;
 
+   mutex_lock(>lock);
*freq = priv->freq_hz + priv->freq_offset;
 
if (debug) {
-   mutex_lock(>lock);
if ((priv->cur_fw.type
 & (BASE | FM | DTV6 | DTV7 | DTV78 | DTV8)) == BASE) {
u16 snr = 0;
@@ -1529,8 +1529,8 @@ static int xc4000_get_frequency(struct dvb_frontend *fe, 
u32 *freq)
return 0;
}
}
-   mutex_unlock(>lock);
}
+   mutex_unlock(>lock);
 
dprintk(1, "%s()\n", __func__);
 


[git:media_stage/master] media: cec.h: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: cec.h: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:03 2024 +

The fields are gone, remove their documentation.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans Verkuil 

 include/media/cec.h | 2 --
 1 file changed, 2 deletions(-)

---

diff --git a/include/media/cec.h b/include/media/cec.h
index d77982685116..10c9cf6058b7 100644
--- a/include/media/cec.h
+++ b/include/media/cec.h
@@ -224,8 +224,6 @@ struct cec_adap_ops {
  * @notifier:  CEC notifier
  * @pin:   CEC pin status struct
  * @cec_dir:   debugfs cec directory
- * @status_file:   debugfs cec status file
- * @error_inj_file:debugfs cec error injection file
  * @sequence:  transmit sequence counter
  * @input_phys:remote control input_phys name
  *


[git:media_stage/master] media: i2c: adv748: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: i2c: adv748: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:06 2024 +

The field is gone, remove the documentation.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Reviewed-by: Kieran Bingham 
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/adv748x/adv748x.h | 1 -
 1 file changed, 1 deletion(-)

---

diff --git a/drivers/media/i2c/adv748x/adv748x.h 
b/drivers/media/i2c/adv748x/adv748x.h
index 6f90f78f58cf..d2b5e722e997 100644
--- a/drivers/media/i2c/adv748x/adv748x.h
+++ b/drivers/media/i2c/adv748x/adv748x.h
@@ -173,7 +173,6 @@ struct adv748x_afe {
  *
  * @endpoints: parsed device node endpoints for each port
  *
- * @i2c_addresses: I2C Page addresses
  * @i2c_clients:   I2C clients for the page accesses
  * @regmap:regmap configuration pages.
  *


[git:media_stage/master] media: i2c: css-quirk.h: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: i2c: css-quirk.h: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:05 2024 +

Kerneldoc does not seem to understand that embed doc:
drivers/media/i2c/ccs/ccs-quirk.h:50: warning: Excess struct member 'write' 
description in 'ccs_quirk'
drivers/media/i2c/ccs/ccs-quirk.h:50: warning: Excess struct member 'reg' 
description in 'ccs_quirk'
drivers/media/i2c/ccs/ccs-quirk.h:50: warning: Excess struct member 'val' 
description in 'ccs_quirk'

Convert into a standard doc.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/ccs/ccs-quirk.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

---

diff --git a/drivers/media/i2c/ccs/ccs-quirk.h 
b/drivers/media/i2c/ccs/ccs-quirk.h
index 0b1a64958d71..392c97109617 100644
--- a/drivers/media/i2c/ccs/ccs-quirk.h
+++ b/drivers/media/i2c/ccs/ccs-quirk.h
@@ -28,11 +28,11 @@ struct ccs_sensor;
  * @reg_access: Register access quirk. The quirk may divert the access
  * to another register, or no register at all.
  *
- * @write: Is this read (false) or write (true) access?
- * @reg: Pointer to the register to access
- * @value: Register value, set by the caller on write, or
+ * -write: Is this read (false) or write (true) access?
+ * -reg:   Pointer to the register to access
+ * -val:   Register value, set by the caller on write, or
  * by the quirk on read
- * @return: 0 on success, -ENOIOCTLCMD if no register
+ * -return: 0 on success, -ENOIOCTLCMD if no register
  *  access may be done by the caller (default read
  *  value is zero), else negative error code on error
  * @flags: Quirk flags


[git:media_stage/master] media: vidioc-subdev-g-client-cap.rst: document struct v4l2_subdev_client_capability

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: vidioc-subdev-g-client-cap.rst: document struct 
v4l2_subdev_client_capability
Author:  Hans Verkuil 
Date:Fri Dec 15 10:38:29 2023 +0100

The struct v4l2_subdev_client_capability was never actually documented,
only the capability flags were documented.

Add this.

Signed-off-by: Hans Verkuil 

 .../media/v4l/vidioc-subdev-g-client-cap.rst  | 15 +++
 1 file changed, 15 insertions(+)

---

diff --git 
a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
index 810b6a859dc8..da4a358ce762 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
@@ -61,6 +61,21 @@ been accepted. A common case for the kernel not accepting a 
capability is that
 the kernel is older than the headers the userspace uses, and thus the 
capability
 is unknown to the kernel.
 
+.. tabularcolumns:: |p{1.5cm}|p{2.9cm}|p{12.9cm}|
+
+.. c:type:: v4l2_subdev_client_capability
+
+.. flat-table:: struct v4l2_subdev_client_capability
+:header-rows:  0
+:stub-columns: 0
+:widths:   3 4 20
+
+* - __u64
+  - ``capabilities``
+  - Sub-device client capabilities of the opened device.
+
+.. tabularcolumns:: |p{6.8cm}|p{2.4cm}|p{8.1cm}|
+
 .. flat-table:: Client Capabilities
 :header-rows:  1
 


[git:media_stage/master] media: verisilicon: Fix some typos

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: verisilicon: Fix some typos
Author:  renjun wang 
Date:Sat Dec 16 12:18:05 2023 +0800

Function hantro_g1_h264_dec_prepare_table() does not exist,
should be replaced with hantro_h264_dec_init().

The register name av1_ulticore_tile_col confused sometimes,
although not be used corrently. The correct name should be
av1_multicore_tile_col.

Signed-off-by: renjun wang 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/verisilicon/hantro_g1_h264_dec.c| 2 +-
 drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c | 2 +-
 drivers/media/platform/verisilicon/rockchip_vpu981_regs.h  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

---

diff --git a/drivers/media/platform/verisilicon/hantro_g1_h264_dec.c 
b/drivers/media/platform/verisilicon/hantro_g1_h264_dec.c
index 9de7f05eff2a..ad5c1a6634f5 100644
--- a/drivers/media/platform/verisilicon/hantro_g1_h264_dec.c
+++ b/drivers/media/platform/verisilicon/hantro_g1_h264_dec.c
@@ -243,7 +243,7 @@ static void set_buffers(struct hantro_ctx *ctx, struct 
vb2_v4l2_buffer *src_buf)
vdpu_write_relaxed(vpu, dst_dma + offset, G1_REG_ADDR_DIR_MV);
}
 
-   /* Auxiliary buffer prepared in hantro_g1_h264_dec_prepare_table(). */
+   /* Auxiliary buffer prepared in hantro_h264_dec_init(). */
vdpu_write_relaxed(vpu, ctx->h264_dec.priv.dma, G1_REG_ADDR_QTABLE);
 }
 
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c 
b/drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c
index 46c1a83bcc4e..6da87f5184bc 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu2_hw_h264_dec.c
@@ -460,7 +460,7 @@ static void set_buffers(struct hantro_ctx *ctx, struct 
vb2_v4l2_buffer *src_buf)
vdpu_write_relaxed(vpu, dst_dma + offset, VDPU_REG_DIR_MV_BASE);
}
 
-   /* Auxiliary buffer prepared in hantro_g1_h264_dec_prepare_table(). */
+   /* Auxiliary buffer prepared in hantro_h264_dec_init(). */
vdpu_write_relaxed(vpu, ctx->h264_dec.priv.dma, VDPU_REG_QTABLE_BASE);
 }
 
diff --git a/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h 
b/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
index 182e6c830ff6..850ff0f84424 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
+++ b/drivers/media/platform/verisilicon/rockchip_vpu981_regs.h
@@ -118,7 +118,7 @@
 #define av1_mcomp_filt_typeAV1_DEC_REG(11, 8, 0x7)
 #define av1_multicore_expect_context_updateAV1_DEC_REG(11, 11, 0x1)
 #define av1_multicore_sbx_offset   AV1_DEC_REG(11, 12, 0x7f)
-#define av1_ulticore_tile_col  AV1_DEC_REG(11, 19, 0x7f)
+#define av1_multicore_tile_col AV1_DEC_REG(11, 19, 0x7f)
 #define av1_transform_mode AV1_DEC_REG(11, 27, 0x7)
 #define av1_dec_tile_size_mag  AV1_DEC_REG(11, 30, 0x3)
 


[git:media_stage/master] media: videobuf2: Fix doc comment

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: videobuf2: Fix doc comment
Author:  Andrzej Pietrasiewicz 
Date:Fri Jan 5 13:54:37 2024 +0100

The documented struct member is called "planes" rather than "vb2_plane".
While at it, make the comments order follow struct members order.

Fixes: 2b1413245550 ("media: vb2-core: Improve kernel-doc markups")
Signed-off-by: Andrzej Pietrasiewicz 
Acked-by: Tomasz Figa 
Signed-off-by: Hans Verkuil 

 include/media/videobuf2-core.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 56719a26a46c..d9c6b5d4e990 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -271,11 +271,11 @@ struct vb2_buffer {
 *  skips cache sync/invalidation.
 * skip_cache_sync_on_finish: when set buffer's ->finish() function
 *  skips cache sync/invalidation.
+* planes:  per-plane information; do not change
 * queued_entry:entry on the queued buffers list, which holds
 *  all buffers queued from userspace
 * done_entry:  entry on the list that stores all buffers ready
 *  to be dequeued to userspace
-* vb2_plane:   per-plane information; do not change
 */
enum vb2_buffer_state   state;
unsigned intsynced:1;


[git:media_stage/master] media: cec: core: remove length check of Timer Status

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: cec: core: remove length check of Timer Status
Author:  Nini Song 
Date:Thu Jan 25 21:28:45 2024 +0800

The valid_la is used to check the length requirements,
including special cases of Timer Status. If the length is
shorter than 5, that means no Duration Available is returned,
the message will be forced to be invalid.

However, the description of Duration Available in the spec
is that this parameter may be returned when these cases, or
that it can be optionally return when these cases. The key
words in the spec description are flexible choices.

Remove the special length check of Timer Status to fit the
spec which is not compulsory about that.

Signed-off-by: Nini Song 
Signed-off-by: Hans Verkuil 

 drivers/media/cec/core/cec-adap.c | 14 --
 1 file changed, 14 deletions(-)

---

diff --git a/drivers/media/cec/core/cec-adap.c 
b/drivers/media/cec/core/cec-adap.c
index 5741adf09a2e..559a172ebc6c 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -1151,20 +1151,6 @@ void cec_received_msg_ts(struct cec_adapter *adap,
if (valid_la && min_len) {
/* These messages have special length requirements */
switch (cmd) {
-   case CEC_MSG_TIMER_STATUS:
-   if (msg->msg[2] & 0x10) {
-   switch (msg->msg[2] & 0xf) {
-   case CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE:
-   case CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE:
-   if (msg->len < 5)
-   valid_la = false;
-   break;
-   }
-   } else if ((msg->msg[2] & 0xf) == 
CEC_OP_PROG_ERROR_DUPLICATE) {
-   if (msg->len < 5)
-   valid_la = false;
-   }
-   break;
case CEC_MSG_RECORD_ON:
switch (msg->msg[2]) {
case CEC_OP_RECORD_SRC_OWN:


[git:media_stage/master] media: v4l2-ctrls: show all owned controls in log_status

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: v4l2-ctrls: show all owned controls in log_status
Author:  Hans Verkuil 
Date:Wed Jan 17 15:52:04 2024 +0100

VIDIOC_LOG_STATUS will log the controls owned by the driver. But the
code didn't take into account the case where a single driver creates
multiple control handlers. A good example is the vivid driver, but
others use it as well.

Modify v4l2_ctrl_handler_log_status() so that it really shows all
controls owned by this driver.

Signed-off-by: Hans Verkuil 

 drivers/media/v4l2-core/v4l2-ctrls-core.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

---

diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c 
b/drivers/media/v4l2-core/v4l2-ctrls-core.c
index a662fb60f73f..0accb96001db 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
@@ -2503,7 +2503,8 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
 EXPORT_SYMBOL(v4l2_ctrl_handler_setup);
 
 /* Log the control name and value */
-static void log_ctrl(const struct v4l2_ctrl *ctrl,
+static void log_ctrl(const struct v4l2_ctrl_handler *hdl,
+struct v4l2_ctrl *ctrl,
 const char *prefix, const char *colon)
 {
if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY))
@@ -2513,7 +2514,11 @@ static void log_ctrl(const struct v4l2_ctrl *ctrl,
 
pr_info("%s%s%s: ", prefix, colon, ctrl->name);
 
+   if (ctrl->handler != hdl)
+   v4l2_ctrl_lock(ctrl);
ctrl->type_ops->log(ctrl);
+   if (ctrl->handler != hdl)
+   v4l2_ctrl_unlock(ctrl);
 
if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE |
   V4L2_CTRL_FLAG_GRABBED |
@@ -2532,7 +2537,7 @@ static void log_ctrl(const struct v4l2_ctrl *ctrl,
 void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
  const char *prefix)
 {
-   struct v4l2_ctrl *ctrl;
+   struct v4l2_ctrl_ref *ref;
const char *colon = "";
int len;
 
@@ -2544,9 +2549,12 @@ void v4l2_ctrl_handler_log_status(struct 
v4l2_ctrl_handler *hdl,
if (len && prefix[len - 1] != ' ')
colon = ": ";
mutex_lock(hdl->lock);
-   list_for_each_entry(ctrl, >ctrls, node)
-   if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED))
-   log_ctrl(ctrl, prefix, colon);
+   list_for_each_entry(ref, >ctrl_refs, node) {
+   if (ref->from_other_dev ||
+   (ref->ctrl->flags & V4L2_CTRL_FLAG_DISABLED))
+   continue;
+   log_ctrl(hdl, ref->ctrl, prefix, colon);
+   }
mutex_unlock(hdl->lock);
 }
 EXPORT_SYMBOL(v4l2_ctrl_handler_log_status);


[git:media_stage/master] media: pci: dt315.h: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: pci: dt315.h: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:04 2024 +

The field is gone, remove it.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans Verkuil 

 drivers/media/pci/dt3155/dt3155.h | 1 -
 1 file changed, 1 deletion(-)

---

diff --git a/drivers/media/pci/dt3155/dt3155.h 
b/drivers/media/pci/dt3155/dt3155.h
index c9ce79cb5566..ce1835d9691e 100644
--- a/drivers/media/pci/dt3155/dt3155.h
+++ b/drivers/media/pci/dt3155/dt3155.h
@@ -162,7 +162,6 @@
  * @height:frame height
  * @input: current input
  * @sequence:  frame counter
- * @stats: statistics structure
  * @regs:  local copy of mmio base register
  * @csr2:  local copy of csr2 register
  * @config:local copy of config register


[git:media_stage/master] media: tc358746: fix the pll calculating function

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: tc358746: fix the pll calculating function
Author:  Duc-Long, Le 
Date:Sat Oct 14 20:19:46 2023 -0400

Following formula of Pll_clk in 5.2 section, 50th page of
TC358746AXBG/748XBG/748IXBG Functional Specification Rev 1.1 document.
The formula of fout is as below:
fout = refclk * mul / (prediv * postdiv)

Remove "p" to avoid using 2 times of prediv in pll calculating function.

Signed-off-by: Duc-Long, Le 
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/tc358746.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c
index 106de4271d2e..d676adc4401b 100644
--- a/drivers/media/i2c/tc358746.c
+++ b/drivers/media/i2c/tc358746.c
@@ -843,14 +843,14 @@ static unsigned long tc358746_find_pll_settings(struct 
tc358746 *tc358746,
if (fin < 4 * HZ_PER_MHZ || fin > 40 * HZ_PER_MHZ)
continue;
 
-   tmp = fout * p * postdiv;
+   tmp = fout * postdiv;
do_div(tmp, fin);
mul = tmp;
if (mul > 511)
continue;
 
tmp = mul * fin;
-   do_div(tmp, p * postdiv);
+   do_div(tmp, postdiv);
 
delta = abs(fout - tmp);
if (delta < min_delta) {


[git:media_stage/master] media: mediatek: jpeg: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mediatek: jpeg: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:07 2024 +

The field is gone, remove the documentation for it.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Hans Verkuil 

 drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h | 1 -
 1 file changed, 1 deletion(-)

---

diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h 
b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h
index 8ba6e757e11a..8877eb39e807 100644
--- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h
+++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h
@@ -144,7 +144,6 @@ struct mtk_jpegdec_clk {
  * @jpegenc_irq:   jpeg encode irq num
  * @job_timeout_work:  encode timeout workqueue
  * @hw_param:  jpeg encode hw parameters
- * @hw_rdy:record hw ready
  * @hw_state:  record hw state
  * @hw_lock:   spinlock protecting the hw device resource
  */


[git:media_stage/master] media: verisilicon: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: verisilicon: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:09 2024 +

The field is not part of the structure. Remove the doc.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/verisilicon/hantro.h | 1 -
 1 file changed, 1 deletion(-)

---

diff --git a/drivers/media/platform/verisilicon/hantro.h 
b/drivers/media/platform/verisilicon/hantro.h
index 6f5eb975d0e3..811260dc3c77 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -237,7 +237,6 @@ struct hantro_dev {
  * @codec_ops: Set of operations related to codec mode.
  * @postproc:  Post-processing context.
  * @h264_dec:  H.264-decoding context.
- * @jpeg_enc:  JPEG-encoding context.
  * @mpeg2_dec: MPEG-2-decoding context.
  * @vp8_dec:   VP8-decoding context.
  * @hevc_dec:  HEVC-decoding context.


[git:media_stage/master] media: mediatek: vcodec: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mediatek: vcodec: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:08 2024 +

Those fields have been removed. They do not need to be documented.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Hans Verkuil 

 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h | 1 -
 drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.h| 1 -
 drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.h | 1 -
 3 files changed, 3 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h 
b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h
index ece27c880e50..1af075fc0194 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.h
@@ -39,7 +39,6 @@ struct vdec_fb {
 /**
  * struct mtk_video_dec_buf - Private data related to each VB2 buffer.
  * @m2m_buf:   M2M buffer
- * @list:  link list
  * @used:  Capture buffer contain decoded frame data and keep in
  * codec data structure
  * @queued_in_vb2: Capture buffer is queue in vb2
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.h 
b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.h
index fbb3f34a73f0..aa7d08afc2f4 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.h
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.h
@@ -22,7 +22,6 @@ struct mtk_vcodec_dec_ctx;
  *in place of inst_addr in messages.
  * @signaled: 1 - Host has received ack message from VPU, 0 - not received
  * @ctx : context for v4l2 layer integration
- * @dev: platform device of VPU
  * @wq  : wait queue to wait VPU message ack
  * @handler : ipi handler for each decoder
  * @codec_type : use codec type to separate different codecs
diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.h 
b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.h
index 82246401ed4a..908d8179b2d2 100644
--- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.h
+++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.h
@@ -26,7 +26,6 @@
 /**
  * struct mtk_video_enc_buf - Private data related to each VB2 buffer.
  * @m2m_buf:   M2M buffer
- * @list:  list that buffer link to
  * @param_change: Types of encode parameter change before encoding this
  * buffer
  * @enc_params: Encode parameters changed before encode this buffer


[git:media_stage/master] media: qcom: venus: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: qcom: venus: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:10 2024 +

Remove doc for missing field.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/qcom/venus/core.h | 1 -
 1 file changed, 1 deletion(-)

---

diff --git a/drivers/media/platform/qcom/venus/core.h 
b/drivers/media/platform/qcom/venus/core.h
index 4a633261ece4..a39986ce79f1 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -428,7 +428,6 @@ enum venus_inst_modes {
  * @error: an error returned during last HFI sync operation
  * @session_error: a flag rised by HFI interface in case of session error
  * @ops:   HFI operations
- * @priv:  a private for HFI operations callbacks
  * @session_type:  the type of the session (decoder or encoder)
  * @hprop: a union used as a holder by get property
  * @core_acquired: the Core has been acquired


[git:media_stage/master] media: samsung: exynos4-is: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: samsung: exynos4-is: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:11 2024 +

Remove doc from missing fields.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/samsung/exynos4-is/fimc-lite.h | 3 ---
 1 file changed, 3 deletions(-)

---

diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-lite.h 
b/drivers/media/platform/samsung/exynos4-is/fimc-lite.h
index ddf29e0b5b1c..2d96fb00a5c6 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-lite.h
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-lite.h
@@ -117,8 +117,6 @@ struct flite_buffer {
  * @ctrl_handler: v4l2 control handler
  * @test_pattern: test pattern controls
  * @index: FIMC-LITE platform device index
- * @pipeline: video capture pipeline data structure
- * @pipeline_ops: media pipeline ops for the video node driver
  * @slock: spinlock protecting this data structure and the hw registers
  * @lock: mutex serializing video device and the subdev operations
  * @clock: FIMC-LITE gate clock
@@ -134,7 +132,6 @@ struct flite_buffer {
  * @active_buf_q: the queue head of buffers scheduled in hardware
  * @vb_queue: vb2 buffers queue
  * @buf_index: helps to keep track of the DMA start address register index
- * @active_buf_count: number of video buffers scheduled in hardware
  * @frame_count: the captured frames counter
  * @reqbufs_count: the number of buffers requested with REQBUFS ioctl
  * @events: event info


[git:media_stage/master] media: samsung: s5p-mfc: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: samsung: s5p-mfc: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:12 2024 +

Remove doc from missing fields.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 1 -
 1 file changed, 1 deletion(-)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
index 0f6e260746c9..3cc2a4f5c40a 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -612,7 +612,6 @@ struct s5p_mfc_codec_ops {
  * @chroma_dpb_size:   dpb buffer size for chroma
  * @me_buffer_size:size of the motion estimation buffer
  * @tmv_buffer_size:   size of temporal predictor motion vector buffer
- * @frame_type:used to force the type of the next encoded frame
  * @ref_queue: list of the reference buffers for encoding
  * @force_frame_type:  encoder's frame type forcing control
  * @ref_queue_cnt: number of the buffers in the reference list


[git:media_stage/master] media: v4l2-tpg: fix some memleaks in tpg_alloc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: v4l2-tpg: fix some memleaks in tpg_alloc
Author:  Zhipeng Lu 
Date:Thu Feb 1 20:47:53 2024 +0800

In tpg_alloc, resources should be deallocated in each and every
error-handling paths, since they are allocated in for statements.
Otherwise there would be memleaks because tpg_free is called only when
tpg_alloc return 0.

Fixes: 63881df94d3e ("[media] vivid: add the Test Pattern Generator")
Signed-off-by: Zhipeng Lu 
Signed-off-by: Hans Verkuil 

 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 52 +--
 1 file changed, 42 insertions(+), 10 deletions(-)

---

diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c 
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index a366566f22c3..642c48e8c1f5 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -113,6 +113,7 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
 {
unsigned pat;
unsigned plane;
+   int ret = 0;
 
tpg->max_line_width = max_w;
for (pat = 0; pat < TPG_MAX_PAT_LINES; pat++) {
@@ -121,14 +122,18 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
 
tpg->lines[pat][plane] =
vzalloc(array3_size(max_w, 2, pixelsz));
-   if (!tpg->lines[pat][plane])
-   return -ENOMEM;
+   if (!tpg->lines[pat][plane]) {
+   ret = -ENOMEM;
+   goto free_lines;
+   }
if (plane == 0)
continue;
tpg->downsampled_lines[pat][plane] =
vzalloc(array3_size(max_w, 2, pixelsz));
-   if (!tpg->downsampled_lines[pat][plane])
-   return -ENOMEM;
+   if (!tpg->downsampled_lines[pat][plane]) {
+   ret = -ENOMEM;
+   goto free_lines;
+   }
}
}
for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
@@ -136,18 +141,45 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
 
tpg->contrast_line[plane] =
vzalloc(array_size(pixelsz, max_w));
-   if (!tpg->contrast_line[plane])
-   return -ENOMEM;
+   if (!tpg->contrast_line[plane]) {
+   ret = -ENOMEM;
+   goto free_contrast_line;
+   }
tpg->black_line[plane] =
vzalloc(array_size(pixelsz, max_w));
-   if (!tpg->black_line[plane])
-   return -ENOMEM;
+   if (!tpg->black_line[plane]) {
+   ret = -ENOMEM;
+   goto free_contrast_line;
+   }
tpg->random_line[plane] =
vzalloc(array3_size(max_w, 2, pixelsz));
-   if (!tpg->random_line[plane])
-   return -ENOMEM;
+   if (!tpg->random_line[plane]) {
+   ret = -ENOMEM;
+   goto free_contrast_line;
+   }
}
return 0;
+
+free_contrast_line:
+   for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
+   vfree(tpg->contrast_line[plane]);
+   vfree(tpg->black_line[plane]);
+   vfree(tpg->random_line[plane]);
+   tpg->contrast_line[plane] = NULL;
+   tpg->black_line[plane] = NULL;
+   tpg->random_line[plane] = NULL;
+   }
+free_lines:
+   for (pat = 0; pat < TPG_MAX_PAT_LINES; pat++)
+   for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
+   vfree(tpg->lines[pat][plane]);
+   tpg->lines[pat][plane] = NULL;
+   if (plane == 0)
+   continue;
+   vfree(tpg->downsampled_lines[pat][plane]);
+   tpg->downsampled_lines[pat][plane] = NULL;
+   }
+   return ret;
 }
 EXPORT_SYMBOL_GPL(tpg_alloc);
 


[git:media_stage/master] media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity
Author:  Zhipeng Lu 
Date:Thu Feb 1 20:48:44 2024 +0800

The entity->name (i.e. name) is allocated in v4l2_m2m_register_entity
but isn't freed in its following error-handling paths. This patch
adds such deallocation to prevent memleak of entity->name.

Fixes: be2fff656322 ("media: add helpers for memory-to-memory media controller")
Signed-off-by: Zhipeng Lu 
Signed-off-by: Hans Verkuil 

 drivers/media/v4l2-core/v4l2-mem2mem.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c 
b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 9e983176542b..75517134a5e9 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -1087,11 +1087,17 @@ static int v4l2_m2m_register_entity(struct media_device 
*mdev,
entity->function = function;
 
ret = media_entity_pads_init(entity, num_pads, pads);
-   if (ret)
+   if (ret) {
+   kfree(entity->name);
+   entity->name = NULL;
return ret;
+   }
ret = media_device_register_entity(mdev, entity);
-   if (ret)
+   if (ret) {
+   kfree(entity->name);
+   entity->name = NULL;
return ret;
+   }
 
return 0;
 }


[git:media_stage/master] MAINTAINERS: Add entry for Samsung MFC DT Schema

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: MAINTAINERS: Add entry for Samsung MFC DT Schema
Author:  Aakarsh Jain 
Date:Wed Jan 31 12:37:41 2024 +0530

Add device tree schema entry for Samsung MFC.

Signed-off-by: Aakarsh Jain 
Signed-off-by: Hans Verkuil 

 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

---

diff --git a/MAINTAINERS b/MAINTAINERS
index 8999497011a2..1a89e0d2ac61 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2752,6 +2752,7 @@ M:Andrzej Hajda 
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
 L: linux-me...@vger.kernel.org
 S: Maintained
+F: Documentation/devicetree/bindings/media/samsung,s5p-mfc.yaml
 F: drivers/media/platform/samsung/s5p-mfc/
 
 ARM/SOCFPGA ARCHITECTURE


[git:media_stage/master] media: dvb-usb: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: dvb-usb: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:13 2024 +

Remove kerneldoc from missing fields.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans Verkuil 

 drivers/media/usb/dvb-usb/dvb-usb.h | 2 --
 1 file changed, 2 deletions(-)

---

diff --git a/drivers/media/usb/dvb-usb/dvb-usb.h 
b/drivers/media/usb/dvb-usb/dvb-usb.h
index 0990aa4a17bb..cbb0541d4dc1 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb.h
+++ b/drivers/media/usb/dvb-usb/dvb-usb.h
@@ -126,8 +126,6 @@ struct usb_data_stream_properties {
  * @caps: capabilities of the DVB USB device.
  * @pid_filter_count: number of PID filter position in the optional hardware
  *  PID-filter.
- * @num_frontends: number of frontends of the DVB USB adapter.
- * @frontend_ctrl: called to power on/off active frontend.
  * @streaming_ctrl: called to start and stop the MPEG2-TS streaming of the
  *  device (not URB submitting/killing).
  *  This callback will be called without data URBs being active - data URBs


[git:media_stage/master] media: staging: meson: Fix kerneldoc

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: staging: meson: Fix kerneldoc
Author:  Ricardo Ribalda 
Date:Fri Jan 26 23:16:15 2024 +

Remove documentation from missing field.

Signed-off-by: Ricardo Ribalda 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans Verkuil 

 drivers/staging/media/meson/vdec/vdec.h | 1 -
 1 file changed, 1 deletion(-)

---

diff --git a/drivers/staging/media/meson/vdec/vdec.h 
b/drivers/staging/media/meson/vdec/vdec.h
index 0906b8fb5cc6..258685177700 100644
--- a/drivers/staging/media/meson/vdec/vdec.h
+++ b/drivers/staging/media/meson/vdec/vdec.h
@@ -101,7 +101,6 @@ struct amvdec_core {
  * @conf_esparser: mandatory call to let the vdec configure the ESPARSER
  * @vififo_level: mandatory call to get the current amount of data
  *   in the VIFIFO
- * @use_offsets: mandatory call. Returns 1 if the VDEC supports vififo offsets
  */
 struct amvdec_ops {
int (*start)(struct amvdec_session *sess);


[git:media_stage/master] media: atomisp: make dbgopt static

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: atomisp: make dbgopt static
Author:  Hans Verkuil 
Date:Fri Feb 2 10:21:20 2024 +0100

This fixes a sparse warning:

drivers/staging/media/atomisp/pci/atomisp_drvfs.c:40:14: warning: symbol 
'dbgopt' was not declared. Should it be static?

Signed-off-by: Hans Verkuil 

 drivers/staging/media/atomisp/pci/atomisp_drvfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_drvfs.c 
b/drivers/staging/media/atomisp/pci/atomisp_drvfs.c
index 293171da1266..ba7dd569a55a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_drvfs.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_drvfs.c
@@ -37,7 +37,7 @@
  *bit 1: running binary
  *bit 2: memory statistic
  */
-unsigned int dbgopt = OPTION_BIN_LIST;
+static unsigned int dbgopt = OPTION_BIN_LIST;
 
 static inline int iunit_dump_dbgopt(struct atomisp_device *isp,
unsigned int opt)


[git:media_stage/master] media: atomisp: don't use sizeof(NULL)

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: atomisp: don't use sizeof(NULL)
Author:  Hans Verkuil 
Date:Fri Feb 2 11:17:30 2024 +0100

Check the size of another pointer instead of NULL. This fixes this
smatch warning:

drivers/staging/media/atomisp/pci/sh_css.c:3609 ia_css_pipe_enqueue_buffer() 
warn: sizeof(NUMBER)?

Signed-off-by: Hans Verkuil 

 drivers/staging/media/atomisp/pci/sh_css.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/drivers/staging/media/atomisp/pci/sh_css.c 
b/drivers/staging/media/atomisp/pci/sh_css.c
index 1d1fbda75da1..938a4ea89c59 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -3606,7 +3606,7 @@ ia_css_pipe_enqueue_buffer(struct ia_css_pipe *pipe,
 
assert(pipeline || pipe_id == IA_CSS_PIPE_ID_COPY);
 
-   assert(sizeof(NULL) <= sizeof(ddr_buffer.kernel_ptr));
+   assert(sizeof(void *) <= sizeof(ddr_buffer.kernel_ptr));
ddr_buffer.kernel_ptr = HOST_ADDRESS(NULL);
ddr_buffer.cookie_ptr = buffer->driver_cookie;
ddr_buffer.timing_data = buffer->timing_data;


[git:media_stage/master] documentation: media: vivid: Modify typo in documentation

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: documentation: media: vivid: Modify typo in documentation
Author:  Dorcas Anono Litunya 
Date:Sat Feb 3 11:58:05 2024 +0300

Correct the default value of node_type vivid parameter to 0xe1d3d.

Signed-off-by: Dorcas Anono Litunya 
Signed-off-by: Hans Verkuil 

 Documentation/admin-guide/media/vivid.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/Documentation/admin-guide/media/vivid.rst 
b/Documentation/admin-guide/media/vivid.rst
index 58ac25b2c385..b6f658c0997e 100644
--- a/Documentation/admin-guide/media/vivid.rst
+++ b/Documentation/admin-guide/media/vivid.rst
@@ -60,7 +60,7 @@ all configurable using the following module options:
 - node_types:
 
which devices should each driver instance create. An array of
-   hexadecimal values, one for each instance. The default is 0x1d3d.
+   hexadecimal values, one for each instance. The default is 0xe1d3d.
Each value is a bitmask with the following meaning:
 
- bit 0: Video Capture node


[git:media_stage/master] media: dt-bindings: techwell,tw9900: Fix port schema ref

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: dt-bindings: techwell,tw9900: Fix port schema ref
Author:  Rob Herring 
Date:Fri Feb 2 16:23:25 2024 -0600

The port@0 node doesn't define any extra properties in the port or endpoint
nodes, so the $ref should be to "/properties/port" instead as it restricts
extra properties.

Fixes: 0f82ffa9a295 ("media: dt-bindings: media: i2c: Add bindings for TW9900")
Signed-off-by: Rob Herring 
Signed-off-by: Hans Verkuil 

 Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml 
b/Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml
index e37317f81072..c9673391afdb 100644
--- a/Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/techwell,tw9900.yaml
@@ -36,7 +36,7 @@ properties:
 
 properties:
   port@0:
-$ref: /schemas/graph.yaml#/$defs/port-base
+$ref: /schemas/graph.yaml#/properties/port
 description: Analog input port
 
 properties:


[git:media_stage/master] media: v4l2-common.h: kerneldoc: correctly format return values

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: v4l2-common.h: kerneldoc: correctly format return values
Author:  Hans Verkuil 
Date:Fri Feb 2 09:25:44 2024 +0100

Building the kerneldoc resulted in two errors:

Documentation/media/driver-api/v4l2-common:6: 
./include/media/v4l2-common.h:566: ERROR: Unexpected indentation.
Documentation/media/driver-api/v4l2-common:6: 
./include/media/v4l2-common.h:567: WARNING: Block quote ends without a blank 
line; unexpected unindent.

Format v4l2_link_freq_to_bitmap according to the kerneldoc standard.
The v4l2_fill_pixfmt_mp function also had incorrect return value
formatting, although that didn't report an error/warning, but it looked
ugly in the generated documentation. So fix that one as well.

Signed-off-by: Hans Verkuil 
Fixes: a68e88e2cf9e ("media: v4l: Add a helper for setting up link-frequencies 
control")
Acked-by: Sakari Ailus 

 include/media/v4l2-common.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

---

diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index cd2163f24f8a..ffed604bc29a 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -536,9 +536,10 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane 
*pixfmt, u32 pixelformat,
  * V4L2_CID_LINK_FREQ control implemented by the transmitter, or value
  * calculated based on the V4L2_CID_PIXEL_RATE implemented by the transmitter.
  *
- * Returns link frequency on success, otherwise a negative error code:
- * -ENOENT: Link frequency or pixel rate control not found
- * -EINVAL: Invalid link frequency value
+ * Return:
+ * * >0: Link frequency
+ * * %-ENOENT: Link frequency or pixel rate control not found
+ * * %-EINVAL: Invalid link frequency value
  */
 s64 v4l2_get_link_freq(struct v4l2_ctrl_handler *handler, unsigned int mul,
   unsigned int div);
@@ -560,11 +561,11 @@ u32 v4l2_fraction_to_interval(u32 numerator, u32 
denominator);
  * system firmware and sets the corresponding bits in @bitmap (after first
  * zeroing it).
  *
- * Return values:
- * 0: Success
- * -ENOENT: No match found between driver-supported link frequencies and
- *  those available in firmware.
- * -ENODATA: No link frequencies were specified in firmware.
+ * Return:
+ * * %0: Success
+ * * %-ENOENT: No match found between driver-supported link frequencies and
+ *   those available in firmware.
+ * * %-ENODATA: No link frequencies were specified in firmware.
  */
 int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
 unsigned int num_of_fw_link_freqs,


[git:media_stage/master] media: cec: make cec_bus_type const

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: cec: make cec_bus_type const
Author:  Ricardo B. Marliere 
Date:Sat Feb 3 12:31:26 2024 -0300

Now that the driver core can properly handle constant struct bus_type,
move the cec_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman 
Suggested-by: Greg Kroah-Hartman 
Signed-off-by: Ricardo B. Marliere 
Reviewed-by: Greg Kroah-Hartman 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 drivers/media/cec/core/cec-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/drivers/media/cec/core/cec-core.c 
b/drivers/media/cec/core/cec-core.c
index 7e153c5cad04..5a54db839e5d 100644
--- a/drivers/media/cec/core/cec-core.c
+++ b/drivers/media/cec/core/cec-core.c
@@ -93,7 +93,7 @@ static void cec_devnode_release(struct device *cd)
cec_delete_adapter(to_cec_adapter(devnode));
 }
 
-static struct bus_type cec_bus_type = {
+static const struct bus_type cec_bus_type = {
.name = CEC_NAME,
 };
 


[git:media_stage/master] media: media-devnode: make media_bus_type const

2024-02-05 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: media-devnode: make media_bus_type const
Author:  Ricardo B. Marliere 
Date:Sat Feb 3 12:31:27 2024 -0300

Now that the driver core can properly handle constant struct bus_type,
move the media_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman 
Suggested-by: Greg Kroah-Hartman 
Signed-off-by: Ricardo B. Marliere 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 drivers/media/mc/mc-devnode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/drivers/media/mc/mc-devnode.c b/drivers/media/mc/mc-devnode.c
index 9c8fe9335dc1..7f67825c8757 100644
--- a/drivers/media/mc/mc-devnode.c
+++ b/drivers/media/mc/mc-devnode.c
@@ -63,7 +63,7 @@ static void media_devnode_release(struct device *cd)
pr_debug("%s: Media Devnode Deallocated\n", __func__);
 }
 
-static struct bus_type media_bus_type = {
+static const struct bus_type media_bus_type = {
.name = MEDIA_NAME,
 };
 


[git:edid-decode/master] edid-decode: let --replace-unique-ids replace dates as well

2024-01-29 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: edid-decode: let --replace-unique-ids replace dates as well
Author:  Hans Verkuil 
Date:Mon Jan 29 14:09:45 2024 +0100

If --replace-unique-ids is given, then replace the 'Made in'
date by the year 2000.

Signed-off-by: Hans Verkuil 

 edid-decode.1 | 17 ++---
 edid-decode.cpp   |  2 +-
 edid-decode.h |  2 ++
 parse-base-block.cpp  | 27 +++
 parse-displayid-block.cpp |  5 +
 5 files changed, 37 insertions(+), 16 deletions(-)

---

diff --git a/edid-decode.1 b/edid-decode.1
index 47bc45b790a1..2b073c267f47 100644
--- a/edid-decode.1
+++ b/edid-decode.1
@@ -253,14 +253,17 @@ the start.
 .TP
 \fB\-\-replace\-unique\-ids\fR
 Replaces any unique IDs in the EDID by fixed values. Serial numbers will be
-replaced by '123456' and Container IDs by all zeroes. This will
-also update any checksums in the EDID and update the EDID hex dump at
-the start of the output. Note that since this will update checksums, any
-checksum errors present in the original EDID will no longer be detected.
+replaced by '123456', Container IDs by all zeroes and the 'Made in' date by
+the year 2000. This will also update any checksums in the EDID and update
+the EDID hex dump at the start of the output. Note that since this will
+update checksums, any checksum errors present in the original EDID will
+no longer be detected.
 
-Serial numbers can appear in the Base Block, DisplayID Extension Blocks and
-Localized String Extension Blocks. Container IDs can appear in the DisplayID
-and CTA-861 Extension Blocks.
+Serial numbers can appear in the Base Block, CTA-861 Extension Blocks,
+DisplayID Extension Blocks and Localized String Extension Blocks.
+Container IDs can appear in the DisplayID and CTA-861 Extension Blocks.
+
+The 'Made in' date appears in the Base Block.
 .TP
 \fB\-\-version\fR
 Show the SHA hash and the last commit date.
diff --git a/edid-decode.cpp b/edid-decode.cpp
index 250d08c0e711..48e5c4d51eb8 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -148,7 +148,7 @@ static void usage(void)
   "  -H, --only-hex-dump   Only output the hex dump of the EDID.\n"
   "  --skip-shaSkip the SHA report.\n"
   "  --hide-serial-numbers Hide serial numbers with '...'.\n"
-  "  --replace-unique-ids  Replace unique IDs (serial numbers, 
Container IDs) with fixed values.\n"
+  "  --replace-unique-ids  Replace unique IDs (serial numbers, 
dates, Container IDs) with fixed values.\n"
   "  --version Show the edid-decode version (SHA).\n"
   "  --diagonalSet the display's diagonal in inches.\n"
   "  --std , Show the standard timing represented by 
these two bytes.\n"
diff --git a/edid-decode.h b/edid-decode.h
index 50abfcbb7bb5..d982f90b72a4 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -158,6 +158,7 @@ struct edid_state {
base.has_640x480p60_est_timing = base.has_spwg =
base.preferred_is_also_native = false;
base.serial_number = 0;
+   base.week = base.year = 0;
base.supports_sec_gtf = false;
base.sec_gtf_start_freq = 0;
base.C = base.M = base.K = base.J = 0;
@@ -250,6 +251,7 @@ struct edid_state {
bool has_name_descriptor;
bool has_display_range_descriptor;
unsigned serial_number;
+   unsigned char week, year;
bool supports_continuous_freq;
bool supports_gtf;
bool supports_sec_gtf;
diff --git a/parse-base-block.cpp b/parse-base-block.cpp
index b58998cd0623..2f2b4f6148fa 100644
--- a/parse-base-block.cpp
+++ b/parse-base-block.cpp
@@ -1384,6 +1384,14 @@ void edid_state::preparse_base_block(unsigned char *x)
update_checksum = true;
}
 
+   base.week = x[0x10];
+   base.year = x[0x11];
+   if (replace_unique_ids && base.week != 0xff) {
+   x[0x10] = 0;
+   x[0x11] = 10;
+   update_checksum = true;
+   }
+
/*
 * Need to find the Display Range Limit info before reading
 * the standard timings.
@@ -1448,8 +1456,8 @@ void edid_state::parse_base_block(const unsigned char *x)
time(_time);
ptm = localtime(_time);
 
-   unsigned char week = x[0x10];
-   int year = 1990 + x[0x11];
+   unsigned char week = base.week;
+   int year = 1990 + base.year;
 
if (week) {
if (base.edid_minor <= 3 && week == 0xff)
@@ -1459,16 +1467,19 @@ void edid_state::parse_base_block(const unsigned char 
*x)
if (base.edid_minor <= 3 && week == 54)
 

[git:edid-decode/master] edid-decode: fix extract_string(): check for non-space after newline

2024-01-29 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: edid-decode: fix extract_string(): check for non-space after newline
Author:  Hans Verkuil 
Date:Mon Jan 29 12:51:11 2024 +0100

The newline character is supposed to terminate the string and
the remainder should be padded with spaces. But some EDIDs
have more text after the newline, which is invalid. It is
probably an attempt to have two lines of text.

Check for this specific case and issue a warning.

Signed-off-by: Hans Verkuil 

 parse-base-block.cpp | 30 ++
 1 file changed, 14 insertions(+), 16 deletions(-)

---

diff --git a/parse-base-block.cpp b/parse-base-block.cpp
index fc0c1b19c7f2..192b6896c006 100644
--- a/parse-base-block.cpp
+++ b/parse-base-block.cpp
@@ -493,29 +493,27 @@ void edid_state::detailed_cvt_descriptor(const char 
*prefix, const unsigned char
 char *extract_string(const unsigned char *x, unsigned len)
 {
static char s[EDID_PAGE_SIZE];
-   int seen_newline = 0;
+   bool seen_newline = false;
unsigned i;
 
memset(s, 0, sizeof(s));
 
for (i = 0; i < len; i++) {
-   if (isgraph(x[i])) {
-   s[i] = x[i];
-   } else if (!seen_newline) {
-   if (x[i] == 0x0a) {
-   seen_newline = 1;
-   if (!i)
-   fail("Empty string.\n");
-   else if (s[i - 1] == 0x20)
-   fail("One or more trailing spaces.\n");
-   } else if (x[i] == 0x20) {
-   s[i] = x[i];
-   } else {
-   fail("Non-printable character.\n");
+   if (seen_newline) {
+   if (x[i] != 0x20) {
+   fail("Non-space after newline.\n");
return s;
}
-   } else if (x[i] != 0x20) {
-   fail("Non-space after newline.\n");
+   } else if (isgraph(x[i]) || x[i] == 0x20) {
+   s[i] = x[i];
+   } else if (x[i] == 0x0a) {
+   seen_newline = true;
+   if (!i)
+   fail("Empty string.\n");
+   else if (s[i - 1] == 0x20)
+   fail("One or more trailing spaces.\n");
+   } else {
+   fail("Non-printable character.\n");
return s;
}
}
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:edid-decode/master] edid-decode: support multiple DTDs with serial numbers

2024-01-29 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: edid-decode: support multiple DTDs with serial numbers
Author:  Hans Verkuil 
Date:Mon Jan 29 12:53:30 2024 +0100

Both the base block and the CTA extension blocks can contain
DTDs with serial numbers. Correctly process those and warn if
multiple serial number DTDs are encountered.

Signed-off-by: Hans Verkuil 

 edid-decode.h|  8 
 parse-base-block.cpp | 20 +---
 parse-cta-block.cpp  |  8 ++--
 3 files changed, 23 insertions(+), 13 deletions(-)

---

diff --git a/edid-decode.h b/edid-decode.h
index 9afc9b5e2f86..50abfcbb7bb5 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -147,17 +147,17 @@ struct edid_state {
hide_serial_numbers = false;
replace_unique_ids = false;
image_width = image_height = diagonal = 0;
+   serial_string_cnt = 0;
+   serial_strings.clear();
 
// Base block state
base.edid_minor = 0;
base.has_name_descriptor = base.has_display_range_descriptor =
-   base.has_serial_string =
base.supports_continuous_freq = base.supports_gtf =
base.supports_cvt = base.seen_non_detailed_descriptor =
base.has_640x480p60_est_timing = base.has_spwg =
base.preferred_is_also_native = false;
base.serial_number = 0;
-   base.serial_string[0] = 0;
base.supports_sec_gtf = false;
base.sec_gtf_start_freq = 0;
base.C = base.M = base.K = base.J = 0;
@@ -225,6 +225,8 @@ struct edid_state {
bool has_dispid;
bool hide_serial_numbers;
bool replace_unique_ids;
+   std::vector serial_strings;
+   unsigned serial_string_cnt;
 
unsigned min_hor_freq_hz;
unsigned max_hor_freq_hz;
@@ -248,8 +250,6 @@ struct edid_state {
bool has_name_descriptor;
bool has_display_range_descriptor;
unsigned serial_number;
-   char serial_string[14];
-   bool has_serial_string;
bool supports_continuous_freq;
bool supports_gtf;
bool supports_sec_gtf;
diff --git a/parse-base-block.cpp b/parse-base-block.cpp
index 192b6896c006..b58998cd0623 100644
--- a/parse-base-block.cpp
+++ b/parse-base-block.cpp
@@ -1119,7 +1119,9 @@ bool edid_state::preparse_detailed_block(unsigned char *x)
}
break;
case 0xff:
-   strcpy(base.serial_string, extract_string(x + 5, 13));
+   data_block = "Display Product Serial Number";
+   serial_strings.push_back(extract_string(x + 5, 13));
+   data_block.clear();
if (replace_unique_ids) {
// Replace with 123456
static const unsigned char sernum[13] = {
@@ -1318,29 +1320,30 @@ void edid_state::detailed_block(const unsigned char *x)
};
 
data_block = "Display Product Serial Number";
-   char *sn = extract_string(x + 5, 13);
+   const char *sn = serial_strings[serial_string_cnt++].c_str();
if (hide_serial_numbers)
printf("%s: ...\n", data_block.c_str());
+   else if (replace_unique_ids)
+   printf("%s: '123456'\n", data_block.c_str());
else
printf("%s: '%s'\n", data_block.c_str(), sn);
-   base.has_serial_string = 1;
bool dummy = true;
// Any serial numbers consisting only of spaces, 0, and/or 1
// characters are always considered dummy values.
-   for (unsigned i = 0; i < strlen(base.serial_string); i++) {
-   if (!strchr(" 01", base.serial_string[i])) {
+   for (unsigned i = 0; i < strlen(sn); i++) {
+   if (!strchr(" 01", sn[i])) {
dummy = false;
break;
}
}
// In addition, check against a list of known dummy S/Ns
for (unsigned i = 0; !dummy && dummy_sn[i]; i++) {
-   if (!strcmp(base.serial_string, dummy_sn[i])) {
+   if (!strcmp(sn, dummy_sn[i])) {
dummy = true;
break;
}
}
-   if (dummy && base.serial_string[0])
+   if (dummy && sn[0])
warn("The serial number is one of the known dummy 
values, is that intended?\n");
  

[git:edid-decode/master] edid-decode: set has_svrs when adding native DTDs

2024-01-29 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: edid-decode: set has_svrs when adding native DTDs
Author:  Hans Verkuil 
Date:Mon Jan 29 09:57:47 2024 +0100

The native DTDs are added as SVRs, but has_svrs wasn't set, so these
'timings' were never resolved to the actual timings.

Fix this.

Signed-off-by: Hans Verkuil 
Fixes: fe04b14 ("edid-decode: check that there really are SVRs to resolve")

 parse-cta-block.cpp | 1 +
 1 file changed, 1 insertion(+)

---

diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 4bcc2717899c..060cbdb65d1c 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -2917,6 +2917,7 @@ void edid_state::parse_cta_block(const unsigned char *x)
 
sprintf(type, "DTD %3u", i + 1);

cta.native_timings.push_back(timings_ext(i + 129, type));
+   cta.has_svrs = true;
}
if (cta.has_hdmi && block_nr != 
(block_map.saw_block_1 ? 2 : 1))
fail("The HDMI Specification requires 
that the first Extension Block (that is not a Block Map) is an CTA-861 
Extension Block.\n");
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:media_stage/master] media: chips-media: wave5: Remove K3 References

2024-01-29 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: chips-media: wave5: Remove K3 References
Author:  Brandon Brnich 
Date:Mon Dec 11 14:59:20 2023 -0600

Change compatible string to match dt bindings for TI devices. K3 family
prefix should not be included as it deviates from naming convention.

Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")
Reported-by: Geert Uytterhoeven 
Closes: 
https://lore.kernel.org/all/CAMuHMdUYOq=q1j=d+eac28hthouaanukuvxmru-mun1plkq...@mail.gmail.com/
Signed-off-by: Brandon Brnich 
Reviewed-by: Nishanth Menon 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/chips-media/wave5/wave5-vpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c 
b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
index bfe4caa79cc9..0d90b5820bef 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
@@ -272,7 +272,7 @@ static const struct wave5_match_data ti_wave521c_data = {
 };
 
 static const struct of_device_id wave5_dt_ids[] = {
-   { .compatible = "ti,k3-j721s2-wave521c", .data = _wave521c_data },
+   { .compatible = "ti,j721s2-wave521c", .data = _wave521c_data },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, wave5_dt_ids);
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:media_stage/master] dt-bindings: media: Remove K3 Family Prefix from Compatible

2024-01-29 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: dt-bindings: media: Remove K3 Family Prefix from Compatible
Author:  Brandon Brnich 
Date:Mon Dec 11 14:59:19 2023 -0600

K3 family prefix is not included in other TI compatible strings. Remove
this prefix to keep naming convention consistent.

Fixes: de4b9f7e371a ("dt-bindings: media: wave5: add yaml devicetree bindings")
Reported-by: Geert Uytterhoeven 
Closes: 
https://lore.kernel.org/all/CAMuHMdUYOq=q1j=d+eac28hthouaanukuvxmru-mun1plkq...@mail.gmail.com/
Signed-off-by: Brandon Brnich 
Acked-by: Krzysztof Kozlowski 
Reviewed-by: Nishanth Menon 
Signed-off-by: Hans Verkuil 

 Documentation/devicetree/bindings/media/cnm,wave521c.yaml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/Documentation/devicetree/bindings/media/cnm,wave521c.yaml 
b/Documentation/devicetree/bindings/media/cnm,wave521c.yaml
index 6d5569e77b7a..6a11c1d11fb5 100644
--- a/Documentation/devicetree/bindings/media/cnm,wave521c.yaml
+++ b/Documentation/devicetree/bindings/media/cnm,wave521c.yaml
@@ -17,7 +17,7 @@ properties:
   compatible:
 items:
   - enum:
-  - ti,k3-j721s2-wave521c
+  - ti,j721s2-wave521c
   - const: cnm,wave521c
 
   reg:
@@ -53,7 +53,7 @@ additionalProperties: false
 examples:
   - |
 vpu: video-codec@12345678 {
-compatible = "ti,k3-j721s2-wave521c", "cnm,wave521c";
+compatible = "ti,j721s2-wave521c", "cnm,wave521c";
 reg = <0x12345678 0x1000>;
 clocks = < 42>;
 interrupts = <42>;
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:media_stage/master] media: vb2: refactor setting flags and caps, fix missing cap

2024-01-29 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: vb2: refactor setting flags and caps, fix missing cap
Author:  Hans Verkuil 
Date:Fri Jan 19 10:03:23 2024 +0100

Several functions implementing VIDIOC_REQBUFS and _CREATE_BUFS all use
almost the same code to fill in the flags and capability fields. Refactor
this into a new vb2_set_flags_and_caps() function that replaces the old
fill_buf_caps() and validate_memory_flags() functions.

This also fixes a bug where vb2_ioctl_create_bufs() would not set the
V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS cap and also not fill in the
max_num_buffers field.

Fixes: d055a76c0065 ("media: core: Report the maximum possible number of 
buffers for the queue")
Signed-off-by: Hans Verkuil 
Reviewed-by: Benjamin Gaignard 
Acked-by: Tomasz Figa 

 drivers/media/common/videobuf2/videobuf2-v4l2.c | 53 -
 1 file changed, 25 insertions(+), 28 deletions(-)

---

diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c 
b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 6380155d8575..c575198e8354 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -671,8 +671,20 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer 
*b)
 }
 EXPORT_SYMBOL(vb2_querybuf);
 
-static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
+static void vb2_set_flags_and_caps(struct vb2_queue *q, u32 memory,
+  u32 *flags, u32 *caps, u32 *max_num_bufs)
 {
+   if (!q->allow_cache_hints || memory != V4L2_MEMORY_MMAP) {
+   /*
+* This needs to clear V4L2_MEMORY_FLAG_NON_COHERENT only,
+* but in order to avoid bugs we zero out all bits.
+*/
+   *flags = 0;
+   } else {
+   /* Clear all unknown flags. */
+   *flags &= V4L2_MEMORY_FLAG_NON_COHERENT;
+   }
+
*caps = V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS;
if (q->io_modes & VB2_MMAP)
*caps |= V4L2_BUF_CAP_SUPPORTS_MMAP;
@@ -686,21 +698,9 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
*caps |= V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS;
if (q->supports_requests)
*caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS;
-}
-
-static void validate_memory_flags(struct vb2_queue *q,
- int memory,
- u32 *flags)
-{
-   if (!q->allow_cache_hints || memory != V4L2_MEMORY_MMAP) {
-   /*
-* This needs to clear V4L2_MEMORY_FLAG_NON_COHERENT only,
-* but in order to avoid bugs we zero out all bits.
-*/
-   *flags = 0;
-   } else {
-   /* Clear all unknown flags. */
-   *flags &= V4L2_MEMORY_FLAG_NON_COHERENT;
+   if (max_num_bufs) {
+   *max_num_bufs = q->max_num_buffers;
+   *caps |= V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS;
}
 }
 
@@ -709,8 +709,8 @@ int vb2_reqbufs(struct vb2_queue *q, struct 
v4l2_requestbuffers *req)
int ret = vb2_verify_memory_type(q, req->memory, req->type);
u32 flags = req->flags;
 
-   fill_buf_caps(q, >capabilities);
-   validate_memory_flags(q, req->memory, );
+   vb2_set_flags_and_caps(q, req->memory, ,
+  >capabilities, NULL);
req->flags = flags;
return ret ? ret : vb2_core_reqbufs(q, req->memory,
req->flags, >count);
@@ -751,11 +751,9 @@ int vb2_create_bufs(struct vb2_queue *q, struct 
v4l2_create_buffers *create)
int ret = vb2_verify_memory_type(q, create->memory, f->type);
unsigned i;
 
-   fill_buf_caps(q, >capabilities);
-   validate_memory_flags(q, create->memory, >flags);
create->index = vb2_get_num_buffers(q);
-   create->max_num_buffers = q->max_num_buffers;
-   create->capabilities |= V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS;
+   vb2_set_flags_and_caps(q, create->memory, >flags,
+  >capabilities, >max_num_buffers);
if (create->count == 0)
return ret != -EBUSY ? ret : 0;
 
@@ -1006,8 +1004,8 @@ int vb2_ioctl_reqbufs(struct file *file, void *priv,
int res = vb2_verify_memory_type(vdev->queue, p->memory, p->type);
u32 flags = p->flags;
 
-   fill_buf_caps(vdev->queue, >capabilities);
-   validate_memory_flags(vdev->queue, p->memory, );
+   vb2_set_flags_and_caps(vdev->queue, p->memory, ,
+  >capabilities, NULL);
p->flags = flags;
if (res)
return res;
@@ -1026,12 +1024,11 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,

[git:media_stage/master] Merge tag 'v6.8-rc2'

2024-01-29 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: Merge tag 'v6.8-rc2'
Author:  Hans Verkuil 
Date:Mon Jan 29 08:59:23 2024 +0100

Linux 6.8-rc2

The vb2 fixes from v6.8-rc2 are needed for the work on the new
vb2 delete buffers feature.

Signed-off-by: Hans Verkuil 

---

___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:media_stage/master] media: media videobuf2: Stop direct calls to queue num_buffers field

2024-01-29 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: media videobuf2: Stop direct calls to queue num_buffers field
Author:  Benjamin Gaignard 
Date:Thu Jan 18 13:14:52 2024 +0100

Use vb2_get_num_buffers() to avoid using queue num_buffers field directly.
This allows us to change how the number of buffers is computed in the
future.

Fixes: d055a76c0065 ("media: core: Report the maximum possible number of 
buffers for the queue")
Signed-off-by: Benjamin Gaignard 
Acked-by: Tomasz Figa 
Signed-off-by: Hans Verkuil 

 drivers/media/common/videobuf2/videobuf2-core.c | 2 +-
 drivers/media/common/videobuf2/videobuf2-v4l2.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c 
b/drivers/media/common/videobuf2/videobuf2-core.c
index 41a832dd1426..b6bf8f232f48 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -989,7 +989,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum 
vb2_memory memory,
bool no_previous_buffers = !q_num_bufs;
int ret = 0;
 
-   if (q->num_buffers == q->max_num_buffers) {
+   if (q_num_bufs == q->max_num_buffers) {
dprintk(q, 1, "maximum number of buffers already allocated\n");
return -ENOBUFS;
}
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c 
b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 54d572c3b515..6380155d8575 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -1029,7 +1029,7 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,
int res = vb2_verify_memory_type(vdev->queue, p->memory,
p->format.type);
 
-   p->index = vdev->queue->num_buffers;
+   p->index = vb2_get_num_buffers(vdev->queue);
fill_buf_caps(vdev->queue, >capabilities);
validate_memory_flags(vdev->queue, p->memory, >flags);
/*
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:media_stage/fixes] dt-bindings: media: Remove K3 Family Prefix from Compatible

2024-01-24 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: dt-bindings: media: Remove K3 Family Prefix from Compatible
Author:  Brandon Brnich 
Date:Mon Dec 11 14:59:19 2023 -0600

K3 family prefix is not included in other TI compatible strings. Remove
this prefix to keep naming convention consistent.

Fixes: de4b9f7e371a ("dt-bindings: media: wave5: add yaml devicetree bindings")
Reported-by: Geert Uytterhoeven 
Closes: 
https://lore.kernel.org/all/CAMuHMdUYOq=q1j=d+eac28hthouaanukuvxmru-mun1plkq...@mail.gmail.com/
Signed-off-by: Brandon Brnich 
Acked-by: Krzysztof Kozlowski 
Reviewed-by: Nishanth Menon 
Signed-off-by: Hans Verkuil 

 Documentation/devicetree/bindings/media/cnm,wave521c.yaml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/Documentation/devicetree/bindings/media/cnm,wave521c.yaml 
b/Documentation/devicetree/bindings/media/cnm,wave521c.yaml
index 6d5569e77b7a..6a11c1d11fb5 100644
--- a/Documentation/devicetree/bindings/media/cnm,wave521c.yaml
+++ b/Documentation/devicetree/bindings/media/cnm,wave521c.yaml
@@ -17,7 +17,7 @@ properties:
   compatible:
 items:
   - enum:
-  - ti,k3-j721s2-wave521c
+  - ti,j721s2-wave521c
   - const: cnm,wave521c
 
   reg:
@@ -53,7 +53,7 @@ additionalProperties: false
 examples:
   - |
 vpu: video-codec@12345678 {
-compatible = "ti,k3-j721s2-wave521c", "cnm,wave521c";
+compatible = "ti,j721s2-wave521c", "cnm,wave521c";
 reg = <0x12345678 0x1000>;
 clocks = < 42>;
 interrupts = <42>;
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:media_stage/fixes] media: media videobuf2: Stop direct calls to queue num_buffers field

2024-01-24 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: media videobuf2: Stop direct calls to queue num_buffers field
Author:  Benjamin Gaignard 
Date:Thu Jan 18 13:14:52 2024 +0100

Use vb2_get_num_buffers() to avoid using queue num_buffers field directly.
This allows us to change how the number of buffers is computed in the
future.

Fixes: d055a76c0065 ("media: core: Report the maximum possible number of 
buffers for the queue")
Signed-off-by: Benjamin Gaignard 
Acked-by: Tomasz Figa 
Signed-off-by: Hans Verkuil 

 drivers/media/common/videobuf2/videobuf2-core.c | 2 +-
 drivers/media/common/videobuf2/videobuf2-v4l2.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c 
b/drivers/media/common/videobuf2/videobuf2-core.c
index 41a832dd1426..b6bf8f232f48 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -989,7 +989,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum 
vb2_memory memory,
bool no_previous_buffers = !q_num_bufs;
int ret = 0;
 
-   if (q->num_buffers == q->max_num_buffers) {
+   if (q_num_bufs == q->max_num_buffers) {
dprintk(q, 1, "maximum number of buffers already allocated\n");
return -ENOBUFS;
}
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c 
b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 54d572c3b515..6380155d8575 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -1029,7 +1029,7 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,
int res = vb2_verify_memory_type(vdev->queue, p->memory,
p->format.type);
 
-   p->index = vdev->queue->num_buffers;
+   p->index = vb2_get_num_buffers(vdev->queue);
fill_buf_caps(vdev->queue, >capabilities);
validate_memory_flags(vdev->queue, p->memory, >flags);
/*
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:media_stage/fixes] media: chips-media: wave5: Remove K3 References

2024-01-24 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: chips-media: wave5: Remove K3 References
Author:  Brandon Brnich 
Date:Mon Dec 11 14:59:20 2023 -0600

Change compatible string to match dt bindings for TI devices. K3 family
prefix should not be included as it deviates from naming convention.

Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")
Reported-by: Geert Uytterhoeven 
Closes: 
https://lore.kernel.org/all/CAMuHMdUYOq=q1j=d+eac28hthouaanukuvxmru-mun1plkq...@mail.gmail.com/
Signed-off-by: Brandon Brnich 
Reviewed-by: Nishanth Menon 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/chips-media/wave5/wave5-vpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c 
b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
index bfe4caa79cc9..0d90b5820bef 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
@@ -272,7 +272,7 @@ static const struct wave5_match_data ti_wave521c_data = {
 };
 
 static const struct of_device_id wave5_dt_ids[] = {
-   { .compatible = "ti,k3-j721s2-wave521c", .data = _wave521c_data },
+   { .compatible = "ti,j721s2-wave521c", .data = _wave521c_data },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, wave5_dt_ids);
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:media_stage/fixes] media: vb2: refactor setting flags and caps, fix missing cap

2024-01-24 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: vb2: refactor setting flags and caps, fix missing cap
Author:  Hans Verkuil 
Date:Fri Jan 19 10:03:23 2024 +0100

Several functions implementing VIDIOC_REQBUFS and _CREATE_BUFS all use
almost the same code to fill in the flags and capability fields. Refactor
this into a new vb2_set_flags_and_caps() function that replaces the old
fill_buf_caps() and validate_memory_flags() functions.

This also fixes a bug where vb2_ioctl_create_bufs() would not set the
V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS cap and also not fill in the
max_num_buffers field.

Fixes: d055a76c0065 ("media: core: Report the maximum possible number of 
buffers for the queue")
Signed-off-by: Hans Verkuil 
Reviewed-by: Benjamin Gaignard 
Acked-by: Tomasz Figa 

 drivers/media/common/videobuf2/videobuf2-v4l2.c | 53 -
 1 file changed, 25 insertions(+), 28 deletions(-)

---

diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c 
b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 6380155d8575..c575198e8354 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -671,8 +671,20 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer 
*b)
 }
 EXPORT_SYMBOL(vb2_querybuf);
 
-static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
+static void vb2_set_flags_and_caps(struct vb2_queue *q, u32 memory,
+  u32 *flags, u32 *caps, u32 *max_num_bufs)
 {
+   if (!q->allow_cache_hints || memory != V4L2_MEMORY_MMAP) {
+   /*
+* This needs to clear V4L2_MEMORY_FLAG_NON_COHERENT only,
+* but in order to avoid bugs we zero out all bits.
+*/
+   *flags = 0;
+   } else {
+   /* Clear all unknown flags. */
+   *flags &= V4L2_MEMORY_FLAG_NON_COHERENT;
+   }
+
*caps = V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS;
if (q->io_modes & VB2_MMAP)
*caps |= V4L2_BUF_CAP_SUPPORTS_MMAP;
@@ -686,21 +698,9 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
*caps |= V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS;
if (q->supports_requests)
*caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS;
-}
-
-static void validate_memory_flags(struct vb2_queue *q,
- int memory,
- u32 *flags)
-{
-   if (!q->allow_cache_hints || memory != V4L2_MEMORY_MMAP) {
-   /*
-* This needs to clear V4L2_MEMORY_FLAG_NON_COHERENT only,
-* but in order to avoid bugs we zero out all bits.
-*/
-   *flags = 0;
-   } else {
-   /* Clear all unknown flags. */
-   *flags &= V4L2_MEMORY_FLAG_NON_COHERENT;
+   if (max_num_bufs) {
+   *max_num_bufs = q->max_num_buffers;
+   *caps |= V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS;
}
 }
 
@@ -709,8 +709,8 @@ int vb2_reqbufs(struct vb2_queue *q, struct 
v4l2_requestbuffers *req)
int ret = vb2_verify_memory_type(q, req->memory, req->type);
u32 flags = req->flags;
 
-   fill_buf_caps(q, >capabilities);
-   validate_memory_flags(q, req->memory, );
+   vb2_set_flags_and_caps(q, req->memory, ,
+  >capabilities, NULL);
req->flags = flags;
return ret ? ret : vb2_core_reqbufs(q, req->memory,
req->flags, >count);
@@ -751,11 +751,9 @@ int vb2_create_bufs(struct vb2_queue *q, struct 
v4l2_create_buffers *create)
int ret = vb2_verify_memory_type(q, create->memory, f->type);
unsigned i;
 
-   fill_buf_caps(q, >capabilities);
-   validate_memory_flags(q, create->memory, >flags);
create->index = vb2_get_num_buffers(q);
-   create->max_num_buffers = q->max_num_buffers;
-   create->capabilities |= V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS;
+   vb2_set_flags_and_caps(q, create->memory, >flags,
+  >capabilities, >max_num_buffers);
if (create->count == 0)
return ret != -EBUSY ? ret : 0;
 
@@ -1006,8 +1004,8 @@ int vb2_ioctl_reqbufs(struct file *file, void *priv,
int res = vb2_verify_memory_type(vdev->queue, p->memory, p->type);
u32 flags = p->flags;
 
-   fill_buf_caps(vdev->queue, >capabilities);
-   validate_memory_flags(vdev->queue, p->memory, );
+   vb2_set_flags_and_caps(vdev->queue, p->memory, ,
+  >capabilities, NULL);
p->flags = flags;
if (res)
return res;
@@ -1026,12 +1024,11 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,

[git:media_stage/master] media: mediatek: vcodec: drop excess struct members descriptions

2024-01-24 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: mediatek: vcodec: drop excess struct members descriptions
Author:  Hans Verkuil 
Date:Mon Jan 22 10:26:42 2024 +0100

Drop obsolete @wait_key_frame and @mv_joint struct member descriptions.

This fixes two warnings:

drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c:57: 
warning: Excess struct member 'wait_key_frame' description in 
'vdec_vp8_slice_info'
drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c:166: 
warning: Excess struct member 'mv_joint' description in 
'vdec_vp9_slice_counts_map'

Signed-off-by: Hans Verkuil 
Reviewed-by: Matthias Brugger 

 drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c| 1 -
 .../media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c| 1 -
 2 files changed, 2 deletions(-)

---

diff --git 
a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c 
b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c
index f64b21c07169..f677e499fefa 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp8_req_if.c
@@ -37,7 +37,6 @@
  * @bs_sz: bitstream size
  * @resolution_changed:resolution change flag 1 - changed,  0 - not change
  * @frame_header_type: current frame header type
- * @wait_key_frame:wait key frame coming
  * @crc:   used to check whether hardware's status is right
  * @reserved:  reserved, currently unused
  */
diff --git 
a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c 
b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
index 69d37b93bd35..cf48d09b78d7 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
@@ -141,7 +141,6 @@ struct vdec_vp9_slice_frame_counts {
  * @skip:  skip counts.
  * @y_mode:Y prediction mode counts.
  * @filter:interpolation filter counts.
- * @mv_joint:  motion vector joint counts.
  * @sign:  motion vector sign counts.
  * @classes:   motion vector class counts.
  * @class0:motion vector class0 bit counts.
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:v4l-utils/master] cv4l-helpers.h: add missing helper functions

2024-01-17 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: cv4l-helpers.h: add missing helper functions
Author:  Hans Verkuil 
Date:Wed Jan 17 10:32:50 2024 +0100

This header was missing has_touch(), has_meta_cap() and has_meta_out().
Add these.

Signed-off-by: Hans Verkuil 

 utils/common/cv4l-helpers.h | 3 +++
 1 file changed, 3 insertions(+)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=2d0a47ad3e7db6e3ecd053dbcee772299eeb82ed
diff --git a/utils/common/cv4l-helpers.h b/utils/common/cv4l-helpers.h
index 397973b9c16f..77c6517a45d1 100644
--- a/utils/common/cv4l-helpers.h
+++ b/utils/common/cv4l-helpers.h
@@ -78,6 +78,9 @@ public:
bool has_rds_out() const { return v4l_has_rds_out(this); }
bool has_sdr_cap() const { return v4l_has_sdr_cap(this); }
bool has_sdr_out() const { return v4l_has_sdr_out(this); }
+   bool has_touch() const { return v4l_has_touch(this); }
+   bool has_meta_cap() const { return v4l_has_meta_cap(this); }
+   bool has_meta_out() const { return v4l_has_meta_out(this); }
bool has_hwseek() const { return v4l_has_hwseek(this); }
bool has_rw() const { return v4l_has_rw(this); }
bool has_streaming() const { return v4l_has_streaming(this); }
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:v4l-utils/master] meson: Fix building with -Dv4l-utils=false

2024-01-17 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: meson: Fix building with -Dv4l-utils=false
Author:  James Le Cuirot 
Date:Tue Dec 12 15:24:05 2023 +

ir_bpf_enabled was referenced without being defined.
Tested-by: Peter Seiderer 

Signed-off-by: Hans Verkuil 

 meson.build | 2 ++
 1 file changed, 2 insertions(+)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=fee976dcfe3be03cc72c099f9ed3bac938a34b58
diff --git a/meson.build b/meson.build
index 3529f6d2f91a..0f35173bb36a 100644
--- a/meson.build
+++ b/meson.build
@@ -383,6 +383,8 @@ subdir('lib')
 if get_option('v4l-utils')
 subdir('utils')
 subdir('contrib')
+else
+ir_bpf_enabled = false
 endif
 
 subdir('doc')
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:v4l-utils/master] meson: Allow documentation directory to be specified with -Ddocdir

2024-01-17 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: meson: Allow documentation directory to be specified with -Ddocdir
Author:  James Le Cuirot 
Date:Tue Dec 12 15:24:06 2023 +

This is needed by Gentoo Linux QA.

Signed-off-by: James Le Cuirot 
Signed-off-by: Hans Verkuil 

 doc/meson.build   | 2 +-
 meson.build   | 5 +
 meson_options.txt | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=87c9abb2cb3ee814f657abf7ffea7a25596f8198
diff --git a/doc/meson.build b/doc/meson.build
index 8f4437e74d72..4b23c3de8991 100644
--- a/doc/meson.build
+++ b/doc/meson.build
@@ -20,7 +20,7 @@ doxygen_install_dirs = []
 doxygen_output = []
 if get_option('doxygen-html')
 doxygen_output += 'html'
-doxygen_install_dirs += get_option('datadir') / 'doc' / 
'@0@'.format(meson.project_name())
+doxygen_install_dirs += docdir
 endif
 if get_option('doxygen-man')
 doxygen_output += 'man'
diff --git a/meson.build b/meson.build
index 0f35173bb36a..900377fa0918 100644
--- a/meson.build
+++ b/meson.build
@@ -307,6 +307,11 @@ if udevdir == ''
 udevdir = '/lib/udev'
 endif
 
+docdir = get_option('docdir')
+if docdir == ''
+docdir = get_option('datadir') / 'doc' / '@0@'.format(meson.project_name())
+endif
+
 qt_opengl_test = '''
 #define GL_GLEXT_PROTOTYPES
 #define QT_NO_OPENGL_ES_2
diff --git a/meson_options.txt b/meson_options.txt
index 2fa046c0dfea..53cf832f5e82 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -32,6 +32,8 @@ option('v4l2-ctl-stream-to', type : 'boolean',
description : 'Enable use of --stream-to in v4l2-ctl')
 
 # Directories
+option('docdir', type : 'string',
+   description : 'Set documentation directory')
 option('gconvsysdir', type : 'string',
description : 'Set system gconv directory (default is to autodetect)')
 option('libv4l1subdir', type : 'string', value : 'libv4l',
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:v4l-utils/master] meson.build: dep_systemd was not set in one case

2024-01-16 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: meson.build: dep_systemd was not set in one case
Author:  Hans Verkuil 
Date:Tue Jan 16 14:26:41 2024 +0100

If the systemdsystemunitdir option was set, then dep_systemd
was never set, causing meson to fail. Just always set this.

Signed-off-by: Hans Verkuil 

 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=daab1df7a7e1b443a0c56e6a8b9f71fda2d037d3
diff --git a/meson.build b/meson.build
index 3196d9a79f0a..3529f6d2f91a 100644
--- a/meson.build
+++ b/meson.build
@@ -273,9 +273,9 @@ if dep_jpeg.found()
 dep_jpeg_priv_libs = '-ljpeg'
 endif
 
+dep_systemd = dependency('systemd', required : false)
 systemd_systemdir = get_option('systemdsystemunitdir')
 if systemd_systemdir == ''
-dep_systemd = dependency('systemd', required : false)
 if dep_systemd.found()
 systemd_systemdir = dep_systemd.get_variable(pkgconfig : 
'systemdsystemunitdir')
 endif
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:v4l-utils/master] v4l2-ctl: report max_num_buffers

2024-01-16 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-ctl: report max_num_buffers
Author:  Hans Verkuil 
Date:Tue Jan 16 11:34:34 2024 +0100

stream_buf_caps() didn't report the max_num_buffers value, just the
corresponding capability flag. Add this.

Signed-off-by: Hans Verkuil 

 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=d18fdf3fc8dd05023c019adc1a5ea386e221c354
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp 
b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 63522e87a3e4..13bc057d857c 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -667,9 +667,16 @@ static void stream_buf_caps(cv4l_fd , unsigned buftype)
cbufs.format.type = buftype;
cbufs.memory = V4L2_MEMORY_MMAP;
if (!v4l_ioctl(fd.g_v4l_fd(), VIDIOC_CREATE_BUFS, )) {
-   printf("Streaming I/O Capabilities for %s: %s\n",
+   bool has_max_num_buffers =
+   cbufs.capabilities & 
V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS;
+
+   cbufs.capabilities &= ~V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS;
+   printf("Streaming I/O Capabilities for %s: %s",
   buftype2s(buftype).c_str(),
   bufcap2s(cbufs.capabilities).c_str());
+   if (has_max_num_buffers)
+   printf(", max-num-buffers=%u", cbufs.max_num_buffers);
+   printf("\n");
return;
}
v4l2_requestbuffers rbufs;
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:v4l-utils/master] qv4l2: support menu controls in updateCtrlRange()

2024-01-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: qv4l2: support menu controls in updateCtrlRange()
Author:  Hans Verkuil 
Date:Mon Jan 15 14:15:58 2024 +0100

When a menu (or integer menu) control was updated with a new
range by the driver, then the corresponding combobox was not
updated. Add support for this.

Signed-off-by: Hans Verkuil 

 utils/qv4l2/ctrl-tab.cpp | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=794987bda0372c9ecc9d61d7f1c780b08b23627b
diff --git a/utils/qv4l2/ctrl-tab.cpp b/utils/qv4l2/ctrl-tab.cpp
index dcf014a86f25..24c11e0897a1 100644
--- a/utils/qv4l2/ctrl-tab.cpp
+++ b/utils/qv4l2/ctrl-tab.cpp
@@ -585,6 +585,8 @@ void ApplicationWindow::updateCtrl(unsigned id)
 void ApplicationWindow::updateCtrlRange(unsigned id, __s32 new_val)
 {
const v4l2_query_ext_ctrl  = m_ctrlMap[id];
+   struct v4l2_querymenu qmenu;
+   QComboBox *combo;
QLineEdit *edit;
QIntValidator *val;
unsigned dif;
@@ -613,9 +615,25 @@ void ApplicationWindow::updateCtrlRange(unsigned id, __s32 
new_val)
break;
 
case V4L2_CTRL_TYPE_STRING:
-   QLineEdit *edit = static_cast(m_widgetMap[id]);
+   edit = static_cast(m_widgetMap[id]);
edit->setMaxLength(qec.maximum);
break;
+
+   case V4L2_CTRL_TYPE_MENU:
+   case V4L2_CTRL_TYPE_INTEGER_MENU:
+   combo = static_cast(m_widgetMap[id]);
+   combo->clear();
+
+   for (int i = (int)qec.minimum; i <= (int)qec.maximum; i++) {
+   qmenu.id = qec.id;
+   qmenu.index = i;
+   if (querymenu(qmenu))
+   continue;
+   if (qec.type == V4L2_CTRL_TYPE_MENU)
+   combo->addItem((char *)qmenu.name);
+   else
+   combo->addItem(QString("%1").arg(qmenu.value));
+   }
}
 }
 
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:edid-decode/master] edid-decode: check that there really are SVRs to resolve

2024-01-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: edid-decode: check that there really are SVRs to resolve
Author:  Hans Verkuil 
Date:Mon Jan 15 09:37:58 2024 +0100

Check if there are really SVRs that need resolving, and
verify that the SVR is in a valid range.

This fixes a segfault for a really crappy EDID.

Signed-off-by: Hans Verkuil 

 edid-decode.cpp | 2 +-
 edid-decode.h   | 2 ++
 parse-cta-block.cpp | 8 
 3 files changed, 11 insertions(+), 1 deletion(-)

---

diff --git a/edid-decode.cpp b/edid-decode.cpp
index 515a3b5d5eff..250d08c0e711 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -1486,7 +1486,7 @@ int edid_state::parse_edid()
block = "";
block_nr = EDID_MAX_BLOCKS;
 
-   if (has_cta)
+   if (cta.has_svrs)
cta_resolve_svrs();
 
if (options[OptPreferredTimings])
diff --git a/edid-decode.h b/edid-decode.h
index b0e26b815ca4..e3e479f2a782 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -179,6 +179,7 @@ struct edid_state {
cta.hf_eeodb_blocks = 0;
cta.image_width = cta.image_height = 0;
cta.block_number = 0;
+   cta.has_svrs = false;
cta.first_svd = true;
cta.supported_hdmi_vic_codes = cta.supported_hdmi_vic_vsb_codes 
= 0;
memset(cta.vics, 0, sizeof(cta.vics));
@@ -309,6 +310,7 @@ struct edid_state {
bool have_hf_vsdb, have_hf_scdb;
unsigned hf_eeodb_blocks;
unsigned block_number;
+   bool has_svrs;
bool first_svd;
unsigned supported_hdmi_vic_codes;
unsigned supported_hdmi_vic_vsb_codes;
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 492e5d2b073d..26e71b0792f9 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -853,6 +853,7 @@ void edid_state::cta_print_svr(unsigned char svr, 
vec_timings_ext _tim)
} else {
printf("%s\n", suffix);
vec_tim.push_back(timings_ext(svr, suffix));
+   cta.has_svrs = true;
}
} else if (svr >= 145 && svr <= 160) {
sprintf(suffix, "VTDB %3u", svr - 144);
@@ -862,6 +863,7 @@ void edid_state::cta_print_svr(unsigned char svr, 
vec_timings_ext _tim)
} else {
printf("%s\n", suffix);
vec_tim.push_back(timings_ext(svr, suffix));
+   cta.has_svrs = true;
}
} else if (svr >= 161 && svr <= 175) {
sprintf(suffix, "RID %u@%up",
@@ -872,6 +874,7 @@ void edid_state::cta_print_svr(unsigned char svr, 
vec_timings_ext _tim)
} else {
printf("%s\n", suffix);
vec_tim.push_back(timings_ext(svr, suffix));
+   cta.has_svrs = true;
}
} else if (svr == 254) {
sprintf(suffix, "T8VTDB");
@@ -882,6 +885,7 @@ void edid_state::cta_print_svr(unsigned char svr, 
vec_timings_ext _tim)
sprintf(suffix, "DMT 0x%02x", cta.preparsed_t8vtdb_dmt);
printf("%s\n", suffix);
vec_tim.push_back(timings_ext(svr, suffix));
+   cta.has_svrs = true;
}
}
 }
@@ -2968,9 +2972,13 @@ void edid_state::cta_resolve_svr(timings_ext _ext)
add_str(t_ext.flags, ">=CTA-861-H");
t_ext.t = cta.t8vtdb.t;
} else if (t_ext.svr() <= 144) {
+   if (t_ext.svr() < 129 || t_ext.svr() - 129 >= 
cta.vec_dtds.size())
+   return;
t_ext.flags = cta.vec_dtds[t_ext.svr() - 129].flags;
t_ext.t = cta.vec_dtds[t_ext.svr() - 129].t;
} else if (t_ext.svr() <= 160) {
+   if (t_ext.svr() - 145 >= cta.vec_vtdbs.size())
+   return;
t_ext.flags = cta.vec_vtdbs[t_ext.svr() - 145].flags;
add_str(t_ext.flags, ">=CTA-861-H");
t_ext.t = cta.vec_vtdbs[t_ext.svr() - 145].t;
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:edid-decode/master] edid-decode: warn that CinemaVRR is deprecated

2024-01-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: edid-decode: warn that CinemaVRR is deprecated
Author:  Hans Verkuil 
Date:Mon Jan 15 09:39:49 2024 +0100

Signed-off-by: Hans Verkuil 

 parse-cta-block.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

---

diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 26e71b0792f9..25cf276f6250 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -1310,8 +1310,10 @@ static void cta_hf_scdb(const unsigned char *x, unsigned 
length)
printf("Supports QMS\n");
if (x[4] & 0x20)
printf("Supports Mdelta\n");
-   if (x[4] & 0x10)
-   printf("Supports media rates below VRRmin (CinemaVRR)\n");
+   if (x[4] & 0x10) {
+   printf("Supports media rates below VRRmin (CinemaVRR, 
deprecated)\n");
+   warn("CinemaVRR is deprecated and must be cleared.\n");
+   }
if (x[4] & 0x08)
printf("Supports negative Mvrr values\n");
if (x[4] & 0x04)
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:edid-decode/master] edid-decode: keep track of the max HDMI TMDS rate

2024-01-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: edid-decode: keep track of the max HDMI TMDS rate
Author:  Hans Verkuil 
Date:Mon Jan 15 09:41:13 2024 +0100

Warn if timings are used that exceed this rate.

Signed-off-by: Hans Verkuil 

 edid-decode.h   |  3 +++
 parse-cta-block.cpp | 22 +++---
 2 files changed, 22 insertions(+), 3 deletions(-)

---

diff --git a/edid-decode.h b/edid-decode.h
index e3e479f2a782..9afc9b5e2f86 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -176,6 +176,7 @@ struct edid_state {
cta.has_nvrdb = false;
cta.previous_cta_tag = 0xfff;
cta.have_hf_vsdb = cta.have_hf_scdb = false;
+   cta.hdmi_max_rate = 0;
cta.hf_eeodb_blocks = 0;
cta.image_width = cta.image_height = 0;
cta.block_number = 0;
@@ -297,6 +298,7 @@ struct edid_state {
bool first_svd_might_be_preferred;
unsigned char byte3;
bool has_hdmi;
+   unsigned hdmi_max_rate;
bool has_vcdb;
bool has_vfpdb;
bool has_nvrdb;
@@ -409,6 +411,7 @@ struct edid_state {
void cta_preparse_sldb(const unsigned char *x, unsigned length);
void cta_colorimetry_block(const unsigned char *x, unsigned length);
void cta_hdmi_block(const unsigned char *x, unsigned length);
+   void cta_hf_scdb(const unsigned char *x, unsigned length);
void cta_displayid_type_7(const unsigned char *x, unsigned length);
void cta_displayid_type_8(const unsigned char *x, unsigned length);
void cta_displayid_type_10(const unsigned char *x, unsigned length);
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 25cf276f6250..4bcc2717899c 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -1009,8 +1009,10 @@ void edid_state::cta_hdmi_block(const unsigned char *x, 
unsigned length)
if (length < 4)
return;
 
-   printf("Maximum TMDS clock: %u MHz\n", x[3] * 5);
-   if (x[3] * 5 > 340)
+   unsigned rate = x[3] * 5;
+   printf("Maximum TMDS clock: %u MHz\n", rate);
+   cta.hdmi_max_rate = rate;
+   if (rate > 340)
fail("HDMI VSDB Max TMDS rate is > 340.\n");
 
if (length < 5)
@@ -1250,7 +1252,7 @@ static void cta_hf_eeodb(const unsigned char *x, unsigned 
length)
fail("Extension Block Count == %u.\n", x[0]);
 }
 
-static void cta_hf_scdb(const unsigned char *x, unsigned length)
+void edid_state::cta_hf_scdb(const unsigned char *x, unsigned length)
 {
unsigned rate = x[1] * 5;
unsigned v;
@@ -1260,6 +1262,10 @@ static void cta_hf_scdb(const unsigned char *x, unsigned 
length)
printf("Maximum TMDS Character Rate: %u MHz\n", rate);
if (rate <= 340 || rate > 600)
fail("Max TMDS rate is > 0 and <= 340 or > 600.\n");
+   if (rate < cta.hdmi_max_rate)
+   fail("HDMI Forum VSDB rate < HDMI VSDB rate.\n");
+   else
+   cta.hdmi_max_rate = rate;
}
if (x[2] & 0x80)
printf("SCDC Present\n");
@@ -1291,6 +1297,12 @@ static void cta_hf_scdb(const unsigned char *x, unsigned 
length)
fail("Max Fixed Rate Link is 1, but Max TMDS rate < 
300.\n");
else if (max_frl_rate >= 2 && rate < 600)
fail("Max Fixed Rate Link is >= 2, but Max TMDS rate < 
600.\n");
+
+   // FIXME:
+   // Currently I do not really know how to translate the
+   // Max FRL value to an equivalent max clock frequency.
+   // So reset this field to 0 to skip any clock rate checks.
+   cta.hdmi_max_rate = 0;
}
if (x[3] & 0x08)
printf("Supports UHD VIC\n");
@@ -3031,6 +3043,10 @@ void edid_state::check_cta_blocks()
if (cta.warn_about_hdmi_2x_dtd)
warn("DTD pixelclock indicates HDMI 2.x support, VICs indicate 
HDMI 1.x.\n");
 
+   if (cta.hdmi_max_rate && max_pixclk_khz > cta.hdmi_max_rate * 1000)
+   fail("The maximum HDMI TMDS clock is %u kHz, but one or more 
video timings go up to %u kHz.\n",
+cta.hdmi_max_rate * 1000, max_pixclk_khz);
+
for (vec_timings_ext::iterator iter = cta.preferred_timings.begin();
 iter != cta.preferred_timings.end(); ++iter) {
if (iter->t.interlaced &&
___
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s


[git:v4l-utils/master] Fixed qv4l2 crash with drivers that implement VIDIOC_ENUM_FRAMESIZES for outputs

2024-01-10 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: Fixed qv4l2 crash with drivers that implement VIDIOC_ENUM_FRAMESIZES 
for outputs
Author:  Martin Tůma 
Date:Tue Jan 9 14:12:44 2024 +0100

When a v4l2 driver implements VIDIOC_ENUM_FRAMESIZES for an output, qv4l2
crashes on accessing the "frame size widget" that does not exist. This patch
adds a proper check for the widget not being NULL.

Signed-off-by: Martin Tůma 
Signed-off-by: Hans Verkuil 

 utils/qv4l2/general-tab.cpp | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=8649f5190970ac7bcfc227bcbc210964e693dd1f
diff --git a/utils/qv4l2/general-tab.cpp b/utils/qv4l2/general-tab.cpp
index ffa44ecaf4b9..bceaab09852d 100644
--- a/utils/qv4l2/general-tab.cpp
+++ b/utils/qv4l2/general-tab.cpp
@@ -2165,13 +2165,16 @@ void GeneralTab::updateFrameSize()
 
ok = !enum_framesizes(frmsize, m_pixelformat);
if (ok && frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
-   do {
-   m_frameSize->addItem(QString("%1x%2")
-   
.arg(frmsize.discrete.width).arg(frmsize.discrete.height));
-   if (frmsize.discrete.width == m_width &&
-   frmsize.discrete.height == m_height)
-   m_frameSize->setCurrentIndex(frmsize.index);
-   } while (!enum_framesizes(frmsize));
+   if (m_frameSize) {
+   do {
+   m_frameSize->addItem(QString("%1x%2")
+   .arg(frmsize.discrete.width)
+   .arg(frmsize.discrete.height));
+   if (frmsize.discrete.width == m_width &&
+   frmsize.discrete.height == m_height)
+   
m_frameSize->setCurrentIndex(frmsize.index);
+   } while (!enum_framesizes(frmsize));
+   }
 
m_discreteSizes = true;
m_frameWidth->setEnabled(false);
@@ -2187,7 +2190,8 @@ void GeneralTab::updateFrameSize()
m_frameHeight->setMaximum(m_height);
m_frameHeight->setValue(m_height);
m_frameHeight->blockSignals(false);
-   m_frameSize->setEnabled(!m_haveBuffers);
+   if (m_frameSize)
+   m_frameSize->setEnabled(!m_haveBuffers);
updateFrameInterval();
return;
}

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:v4l-utils/master] v4l2-ctl/compliance: read and show the subdev client capabilities

2023-12-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-ctl/compliance: read and show the subdev client capabilities
Author:  Hans Verkuil 
Date:Fri Dec 15 10:58:23 2023 +0100

Report the subdev client capabilities in v4l2-ctl and v4l2-compliance.

Signed-off-by: Hans Verkuil 

 utils/common/v4l2-info.cpp| 16 +++-
 utils/common/v4l2-info.h  |  6 +-
 utils/v4l2-compliance/v4l2-compliance.cpp |  6 +-
 utils/v4l2-ctl/v4l2-ctl.cpp   | 11 ---
 4 files changed, 33 insertions(+), 6 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=2b2ba7e0e86c4e33f485bfda931245e26bc04549
diff --git a/utils/common/v4l2-info.cpp b/utils/common/v4l2-info.cpp
index ffcc2e87852b..72731bad8016 100644
--- a/utils/common/v4l2-info.cpp
+++ b/utils/common/v4l2-info.cpp
@@ -128,7 +128,8 @@ void v4l2_info_capability(const v4l2_capability )
}
 }
 
-void v4l2_info_subdev_capability(const v4l2_subdev_capability )
+void v4l2_info_subdev_capability(const v4l2_subdev_capability ,
+const v4l2_subdev_client_capability 
)
 {
printf("\tDriver version   : %d.%d.%d\n",
   subdevcap.version >> 16,
@@ -136,6 +137,8 @@ void v4l2_info_subdev_capability(const 
v4l2_subdev_capability )
   subdevcap.version & 0xff);
printf("\tCapabilities : 0x%08x\n", subdevcap.capabilities);
printf("%s", subdevcap2s(subdevcap.capabilities).c_str());
+   printf("\tClient Capabilities: 0x%016llx\n", 
subdevclientcap.capabilities);
+   printf("%s", subdevclientcap2s(subdevclientcap.capabilities).c_str());
 }
 
 std::string fcc2s(__u32 val)
@@ -873,3 +876,14 @@ std::string modulation2s(unsigned modulation)
}
return "Unknown";
 }
+
+std::string subdevclientcap2s(__u64 cap)
+{
+   std::string s;
+
+   if (cap & V4L2_SUBDEV_CLIENT_CAP_STREAMS)
+   s += "streams ";
+   if (cap & V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH)
+   s += "interval-uses-which ";
+   return s;
+}
diff --git a/utils/common/v4l2-info.h b/utils/common/v4l2-info.h
index 2142952a27ff..ac227971b709 100644
--- a/utils/common/v4l2-info.h
+++ b/utils/common/v4l2-info.h
@@ -34,7 +34,8 @@ std::string flags2s(unsigned val, const flag_def *def);
 
 /* Print capability information */
 void v4l2_info_capability(const v4l2_capability );
-void v4l2_info_subdev_capability(const v4l2_subdev_capability );
+void v4l2_info_subdev_capability(const v4l2_subdev_capability ,
+const v4l2_subdev_client_capability 
);
 
 /* Return fourcc pixelformat string */
 std::string fcc2s(__u32 val);
@@ -157,4 +158,7 @@ std::string tcap2s(unsigned cap);
 /* Return band modulation description */
 std::string modulation2s(unsigned modulation);
 
+/* Return subdev client capabilities description */
+std::string subdevclientcap2s(__u64 cap);
+
 #endif
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp 
b/utils/v4l2-compliance/v4l2-compliance.cpp
index b670b78d2c95..9e2c6983637a 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -973,6 +973,7 @@ void testNode(struct node , struct node _m2m_cap, 
struct node _
struct node node2;
struct v4l2_capability vcap = {};
struct v4l2_subdev_capability subdevcap = {};
+   struct v4l2_subdev_client_capability subdevclientcap = {};
std::string driver;
 
tests_total = tests_ok = warnings = 0;
@@ -993,6 +994,9 @@ void testNode(struct node , struct node _m2m_cap, 
struct node _
determine_codec_mask(node);
} else if (node.is_subdev()) {
doioctl(, VIDIOC_SUBDEV_QUERYCAP, );
+   subdevclientcap.capabilities = ~0ULL;
+   if (doioctl(, VIDIOC_SUBDEV_S_CLIENT_CAP, 
))
+   subdevclientcap.capabilities = 0ULL;
} else {
memset(, 0, sizeof(vcap));
}
@@ -1079,7 +1083,7 @@ void testNode(struct node , struct node 
_m2m_cap, struct node _
}
} else if (node.is_subdev()) {
printf("Driver Info:\n");
-   v4l2_info_subdev_capability(subdevcap);
+   v4l2_info_subdev_capability(subdevcap, subdevclientcap);
}
 
__u32 ent_id = 0;
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 4cd84f78e134..e195ad8e4ded 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -1138,6 +1138,7 @@ int main(int argc, char **argv)
const char *export_device = nullptr;
struct v4l2_capability vcap = {};
struct v4l2_subdev_capability subdevcap = {};
+   struct v4l2_subdev_client_capability subdev

[git:v4l-utils/master] *v4l-helpers: support V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH

2023-12-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: *v4l-helpers: support V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH
Author:  Hans Verkuil 
Date:Thu Dec 14 13:12:21 2023 +0100

Add support for that client capability.

Signed-off-by: Hans Verkuil 

 utils/common/cv4l-helpers.h | 1 +
 utils/common/v4l-helpers.h  | 5 -
 2 files changed, 5 insertions(+), 1 deletion(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=61b25a7ede38b688d4fa71fbc59cd9e2f36ea36d
diff --git a/utils/common/cv4l-helpers.h b/utils/common/cv4l-helpers.h
index 199aca365a44..397973b9c16f 100644
--- a/utils/common/cv4l-helpers.h
+++ b/utils/common/cv4l-helpers.h
@@ -83,6 +83,7 @@ public:
bool has_streaming() const { return v4l_has_streaming(this); }
bool has_ext_pix_format() const { return v4l_has_ext_pix_format(this); }
bool has_streams() const { return have_streams; }
+   bool has_ival_uses_which() const { return ival_uses_which; }
 
int querycap(v4l2_capability , bool force = false)
{
diff --git a/utils/common/v4l-helpers.h b/utils/common/v4l-helpers.h
index cf0e92df12e4..7387b6212a57 100644
--- a/utils/common/v4l-helpers.h
+++ b/utils/common/v4l-helpers.h
@@ -41,6 +41,7 @@ struct v4l_fd {
bool is_subdev;
bool is_media;
bool have_streams;
+   bool ival_uses_which;
 
int (*open)(struct v4l_fd *f, const char *file, int oflag, ...);
int (*close)(struct v4l_fd *f);
@@ -539,10 +540,12 @@ static inline int v4l_subdev_s_fd(struct v4l_fd *f, int 
fd, const char *devname)
ret = ioctl(f->fd, VIDIOC_SUBDEV_QUERYCAP, );
subdev_streams = !ret && (subdevcap.capabilities & 
V4L2_SUBDEV_CAP_STREAMS);
 
-   clientcap.capabilities = V4L2_SUBDEV_CLIENT_CAP_STREAMS;
+   clientcap.capabilities = V4L2_SUBDEV_CLIENT_CAP_STREAMS |
+V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH;
 
ret = ioctl(f->fd, VIDIOC_SUBDEV_S_CLIENT_CAP, );
client_streams = !ret && (clientcap.capabilities & 
V4L2_SUBDEV_CLIENT_CAP_STREAMS);
+   f->ival_uses_which = !ret && (clientcap.capabilities & 
V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH);
 
f->have_streams = subdev_streams && client_streams;
 

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:v4l-utils/master] v4l2-ctl: add support for V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH

2023-12-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-ctl: add support for V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH
Author:  Hans Verkuil 
Date:Thu Dec 14 14:25:20 2023 +0100

This doesn't do a lot other than setting 'which' to ACTIVE if this
is supported.

Signed-off-by: Hans Verkuil 

 utils/v4l2-ctl/v4l2-ctl-subdev.cpp | 4 
 1 file changed, 4 insertions(+)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=07f01c35389850f3c22e1c4eedf1b61827430761
diff --git a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp 
b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp
index b6d115fea108..86e6c6897f01 100644
--- a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp
@@ -660,6 +660,8 @@ void subdev_set(cv4l_fd &_fd)
memset(, 0, sizeof(fival));
fival.pad = set_fps_pad;
fival.stream = set_fps_stream;
+   if (_fd.has_ival_uses_which())
+   fival.which = V4L2_SUBDEV_FORMAT_ACTIVE;
 
if (set_fps <= 0) {
fprintf(stderr, "invalid fps %f\n", set_fps);
@@ -798,6 +800,8 @@ void subdev_get(cv4l_fd &_fd)
memset(, 0, sizeof(fival));
fival.pad = get_fps_pad;
fival.stream = get_fps_stream;
+   if (_fd.has_ival_uses_which())
+   fival.which = V4L2_SUBDEV_FORMAT_ACTIVE;
 
printf("ioctl: VIDIOC_SUBDEV_G_FRAME_INTERVAL 
(pad=%u,stream=%u)\n", fival.pad, fival.stream);
if (doioctl(fd, VIDIOC_SUBDEV_G_FRAME_INTERVAL, ) == 0) {

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:v4l-utils/master] v4l2-compliance: add support for V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH

2023-12-15 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-compliance: add support for 
V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH
Author:  Hans Verkuil 
Date:Thu Dec 14 14:26:28 2023 +0100

Improve the g/s_frame_interval tests to use the new 'which' field
if it is available.

Signed-off-by: Hans Verkuil 

 utils/v4l2-compliance/v4l2-compliance.cpp   | 12 ++--
 utils/v4l2-compliance/v4l2-compliance.h |  3 ++-
 utils/v4l2-compliance/v4l2-test-subdevs.cpp | 27 ++-
 3 files changed, 38 insertions(+), 4 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=36b515806f81256c06ebcae13860925f51466f62
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp 
b/utils/v4l2-compliance/v4l2-compliance.cpp
index a83d6413b836..b670b78d2c95 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -1341,8 +1341,9 @@ void testNode(struct node , struct node 
_m2m_cap, struct node _
   which ? "Active" : "Try",
   ok(testSubDevSelection(, 
which, pad, stream)));
if (which)
-   printf("\ttest 
VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: %s\n",
-  
ok(testSubDevFrameInterval(, pad, stream)));
+   printf("\ttest %s 
VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: %s\n",
+  which ? "Active" : "Try",
+  
ok(testSubDevFrameInterval(, which, pad, stream)));
}
}
 
@@ -1365,6 +1366,13 @@ void testNode(struct node , struct node 
_m2m_cap, struct node _
if (node.has_subdev_selection &&
node.has_subdev_selection != 
node.has_subdev_fmt)
fail("VIDIOC_SUBDEV_G/S_SELECTION: 
fmt/selection mismatch\n");
+   if (node.has_ival_uses_which()) {
+   if (node.has_subdev_frame_interval && 
node.has_subdev_frame_interval < 3)
+   
fail("VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: try/active mismatch\n");
+   if (node.has_subdev_frame_interval &&
+   node.has_subdev_frame_interval != 
node.has_subdev_fmt)
+   
fail("VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: fmt/frame_interval mismatch\n");
+   }
}
printf("\n");
}
diff --git a/utils/v4l2-compliance/v4l2-compliance.h 
b/utils/v4l2-compliance/v4l2-compliance.h
index 4f9aa17e3749..0cfc9a378e99 100644
--- a/utils/v4l2-compliance/v4l2-compliance.h
+++ b/utils/v4l2-compliance/v4l2-compliance.h
@@ -149,6 +149,7 @@ struct base_node {
__u8 has_subdev_enum_fival;
__u8 has_subdev_fmt;
__u8 has_subdev_selection;
+   __u8 has_subdev_frame_interval;
int frame_interval_pad;
int enum_frame_interval_pad;
__u32 fbuf_caps;
@@ -375,7 +376,7 @@ int testSubDevCap(struct node *node);
 int testSubDevEnum(struct node *node, unsigned which, unsigned pad, unsigned 
stream);
 int testSubDevFormat(struct node *node, unsigned which, unsigned pad, unsigned 
stream);
 int testSubDevSelection(struct node *node, unsigned which, unsigned pad, 
unsigned stream);
-int testSubDevFrameInterval(struct node *node, unsigned pad, unsigned stream);
+int testSubDevFrameInterval(struct node *node, unsigned which, unsigned pad, 
unsigned stream);
 int testSubDevRouting(struct node *node, unsigned which);
 
 // Buffer ioctl tests
diff --git a/utils/v4l2-compliance/v4l2-test-subdevs.cpp 
b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
index 38339ee3d083..ebca1b94f5c0 100644
--- a/utils/v4l2-compliance/v4l2-test-subdevs.cpp
+++ b/utils/v4l2-compliance/v4l2-test-subdevs.cpp
@@ -272,25 +272,38 @@ int testSubDevEnum(struct node *node, unsigned which, 
unsigned pad, unsigned str
return 0;
 }
 
-int testSubDevFrameInterval(struct node *node, unsigned pad, unsigned stream)
+int testSubDevFrameInterval(struct node *node, unsigned which, unsigned pad, 
unsigned stream)
 {
struct v4l2_subdev_frame_interval fival;
struct v4l2_fract ival;
+   bool has_which = node->has_ival_uses_which();
int ret;
 
+   if (!has_which)
+   which = V4L2_SUBDEV_FORMAT_ACTIVE;
memset(, 0xff, sizeof(fival));
fiva

[git:media_stage/master] media: i2c: mt9m114: use fsleep() in place of udelay()

2023-12-14 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: i2c: mt9m114: use fsleep() in place of udelay()
Author:  Arnd Bergmann 
Date:Wed Dec 13 12:23:07 2023 +0100

With clang-16, building without COMMON_CLK triggers a range check on
udelay() because of a constant division-by-zero calculation:

ld.lld: error: undefined symbol: __bad_udelay
>>> referenced by mt9m114.c
>>>   drivers/media/i2c/mt9m114.o:(mt9m114_power_on) in archive 
>>> vmlinux.a

In this configuration, the driver already fails to probe, before
this function gets called, so it's enough to suppress the assertion.

Do this by using fsleep(), which turns long delays into sleep() calls
in place of the link failure.

This is probably a good idea regardless to avoid overly long dynamic
udelay() calls on a slow clock.

Cc: Sakari Ailus 
Fixes: 24d756e914fc ("media: i2c: Add driver for onsemi MT9M114 camera sensor")
Signed-off-by: Arnd Bergmann 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Tomi Valkeinen 
Signed-off-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/mt9m114.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
index 427eae13ce26..5f0b0ad8f885 100644
--- a/drivers/media/i2c/mt9m114.c
+++ b/drivers/media/i2c/mt9m114.c
@@ -2132,7 +2132,7 @@ static int mt9m114_power_on(struct mt9m114 *sensor)
duration = DIV_ROUND_UP(2 * 50 * 100, freq);
 
gpiod_set_value(sensor->reset, 1);
-   udelay(duration);
+   fsleep(duration);
gpiod_set_value(sensor->reset, 0);
} else {
/*

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: videobuf2: core: Rename min_buffers_needed field in vb2_queue

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: videobuf2: core: Rename min_buffers_needed field in vb2_queue
Author:  Benjamin Gaignard 
Date:Mon Dec 11 14:32:49 2023 +0100

Rename min_buffers_needed into min_queued_buffers and update
the documentation about it.

Signed-off-by: Benjamin Gaignard 
Signed-off-by: Hans Verkuil 
[hverkuil: Drop the change where min_queued_buffers + 1 buffers would be]
[hverkuil: allocated. Now this patch only renames this field instead of making]
[hverkuil: a functional change as well.]
[hverkuil: Renamed 3 remaining min_buffers_needed occurrences.]

 drivers/input/touchscreen/atmel_mxt_ts.c   |  2 +-
 drivers/input/touchscreen/sur40.c  |  2 +-
 drivers/media/common/saa7146/saa7146_fops.c|  2 +-
 drivers/media/common/videobuf2/videobuf2-core.c| 28 +++---
 drivers/media/dvb-core/dvb_vb2.c   |  2 +-
 drivers/media/i2c/video-i2c.c  |  2 +-
 drivers/media/pci/bt8xx/bttv-driver.c  |  2 +-
 drivers/media/pci/cobalt/cobalt-v4l2.c |  2 +-
 drivers/media/pci/cx18/cx18-streams.c  |  2 +-
 drivers/media/pci/cx23885/cx23885-417.c|  2 +-
 drivers/media/pci/cx23885/cx23885-dvb.c|  2 +-
 drivers/media/pci/cx23885/cx23885-video.c  |  4 ++--
 drivers/media/pci/cx25821/cx25821-video.c  |  2 +-
 drivers/media/pci/cx88/cx88-blackbird.c|  2 +-
 drivers/media/pci/cx88/cx88-dvb.c  |  2 +-
 drivers/media/pci/cx88/cx88-video.c|  4 ++--
 drivers/media/pci/dt3155/dt3155.c  |  2 +-
 drivers/media/pci/intel/ipu3/ipu3-cio2.c   |  2 +-
 drivers/media/pci/mgb4/mgb4_vin.c  |  2 +-
 drivers/media/pci/mgb4/mgb4_vout.c |  2 +-
 drivers/media/pci/tw5864/tw5864-video.c|  2 +-
 drivers/media/pci/tw68/tw68-video.c|  2 +-
 drivers/media/pci/tw686x/tw686x-video.c|  2 +-
 drivers/media/pci/zoran/zoran_driver.c |  6 ++---
 drivers/media/platform/amphion/vpu_v4l2.c  |  4 ++--
 drivers/media/platform/aspeed/aspeed-video.c   |  2 +-
 drivers/media/platform/atmel/atmel-isi.c   |  2 +-
 .../media/platform/chips-media/coda/coda-common.c  |  2 +-
 .../media/platform/microchip/microchip-isc-base.c  |  2 +-
 drivers/media/platform/nuvoton/npcm-video.c|  2 +-
 drivers/media/platform/nxp/imx7-media-csi.c|  2 +-
 .../media/platform/nxp/imx8-isi/imx8-isi-video.c   |  2 +-
 drivers/media/platform/qcom/venus/vdec.c   |  4 ++--
 drivers/media/platform/qcom/venus/venc.c   |  4 ++--
 drivers/media/platform/renesas/rcar-vin/rcar-dma.c |  2 +-
 drivers/media/platform/renesas/renesas-ceu.c   |  2 +-
 .../media/platform/renesas/rzg2l-cru/rzg2l-video.c |  2 +-
 drivers/media/platform/renesas/sh_vou.c|  2 +-
 .../platform/rockchip/rkisp1/rkisp1-capture.c  |  2 +-
 drivers/media/platform/st/sti/hva/hva-v4l2.c   |  4 ++--
 drivers/media/platform/st/stm32/stm32-dcmi.c   |  2 +-
 .../st/stm32/stm32-dcmipp/dcmipp-bytecap.c |  4 ++--
 drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c |  2 +-
 .../platform/sunxi/sun6i-csi/sun6i_csi_capture.c   |  2 +-
 drivers/media/platform/sunxi/sun8i-di/sun8i-di.c   |  4 ++--
 .../platform/sunxi/sun8i-rotate/sun8i_rotate.c |  4 ++--
 drivers/media/platform/ti/am437x/am437x-vpfe.c |  2 +-
 drivers/media/platform/ti/cal/cal-video.c  |  2 +-
 drivers/media/platform/ti/davinci/vpif_capture.c   |  2 +-
 drivers/media/platform/ti/davinci/vpif_display.c   |  2 +-
 .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c  |  2 +-
 drivers/media/platform/ti/omap/omap_vout.c |  2 +-
 drivers/media/test-drivers/vimc/vimc-capture.c |  2 +-
 drivers/media/test-drivers/vivid/vivid-core.c  |  4 ++--
 drivers/media/usb/cx231xx/cx231xx-417.c|  2 +-
 drivers/media/usb/cx231xx/cx231xx-video.c  |  4 ++--
 drivers/media/usb/dvb-usb/cxusb-analog.c   |  2 +-
 drivers/media/usb/gspca/gspca.c|  6 ++---
 .../media/deprecated/atmel/atmel-isc-base.c|  2 +-
 drivers/staging/media/imx/imx-media-capture.c  |  2 +-
 drivers/staging/media/ipu3/ipu3-v4l2.c |  2 +-
 drivers/staging/media/meson/vdec/vdec.c|  6 ++---
 drivers/staging/media/starfive/camss/stf-video.c   |  2 +-
 .../media/sunxi/sun6i-isp/sun6i_isp_capture.c  |  2 +-
 .../media/sunxi/sun6i-isp/sun6i_isp_params.c   |  2 +-
 drivers/staging/media/tegra-video/vi.c |  2 +-
 include/media/videobuf2-core.h |  9 ---
 samples/v4l/v4l2-pci-skeleton.c|  2 +-
 68 files changed, 103 insertions(+), 100 deletions(-)

---

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c 
b/drivers/input/touchscreen/atmel_mxt_ts.c
index 20094b9899f0..a2c4b3b87f93 100644

[git:v4l-utils/master] v4l-utils: v4l-utils: sync with latest kernel headers

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l-utils: v4l-utils: sync with latest kernel headers
Author:  Hans Verkuil 
Date:Wed Dec 13 16:59:44 2023 +0100

Signed-off-by: Hans Verkuil 

 include/linux/v4l2-subdev.h | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=afde5e732abb98ae233b1e61d795d2148070d66b
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h
index f0fbb4a7c150..7048c51581c6 100644
--- a/include/linux/v4l2-subdev.h
+++ b/include/linux/v4l2-subdev.h
@@ -116,13 +116,15 @@ struct v4l2_subdev_frame_size_enum {
  * @pad: pad number, as reported by the media API
  * @interval: frame interval in seconds
  * @stream: stream number, defined in subdev routing
+ * @which: interval type (from enum v4l2_subdev_format_whence)
  * @reserved: drivers and applications must zero this array
  */
 struct v4l2_subdev_frame_interval {
__u32 pad;
struct v4l2_fract interval;
__u32 stream;
-   __u32 reserved[8];
+   __u32 which;
+   __u32 reserved[7];
 };
 
 /**
@@ -133,7 +135,7 @@ struct v4l2_subdev_frame_interval {
  * @width: frame width in pixels
  * @height: frame height in pixels
  * @interval: frame interval in seconds
- * @which: format type (from enum v4l2_subdev_format_whence)
+ * @which: interval type (from enum v4l2_subdev_format_whence)
  * @stream: stream number, defined in subdev routing
  * @reserved: drivers and applications must zero this array
  */
@@ -239,7 +241,14 @@ struct v4l2_subdev_routing {
  * set (which is the default), the 'stream' fields will be forced to 0 by the
  * kernel.
  */
-#define V4L2_SUBDEV_CLIENT_CAP_STREAMS (1ULL << 0)
+#define V4L2_SUBDEV_CLIENT_CAP_STREAMS (1ULL << 0)
+
+/*
+ * The client is aware of the struct v4l2_subdev_frame_interval which field. If
+ * this is not set (which is the default), the which field is forced to
+ * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
+ */
+#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH (1ULL << 1)
 
 /**
  * struct v4l2_subdev_client_capability - Capabilities of the client accessing

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: i2c: thp7312: Store frame interval in subdev state

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: i2c: thp7312: Store frame interval in subdev state
Author:  Laurent Pinchart 
Date:Wed Dec 13 17:00:10 2023 +0200

Use the newly added storage for frame interval in the subdev state to
simplify the driver.

Signed-off-by: Laurent Pinchart 
Acked-by: Hans Verkuil 
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/thp7312.c | 158 +++-
 1 file changed, 81 insertions(+), 77 deletions(-)

---

diff --git a/drivers/media/i2c/thp7312.c b/drivers/media/i2c/thp7312.c
index ad4f2b794e1a..2806887514dc 100644
--- a/drivers/media/i2c/thp7312.c
+++ b/drivers/media/i2c/thp7312.c
@@ -266,9 +266,6 @@ struct thp7312_device {
struct v4l2_ctrl_handler ctrl_handler;
bool ctrls_applied;
 
-   /* These are protected by v4l2 active state */
-   const struct thp7312_mode_info *current_mode;
-   const struct thp7312_frame_rate *current_rate;
s64 link_freq;
 
struct {
@@ -310,6 +307,47 @@ static inline struct thp7312_device *to_thp7312_dev(struct 
v4l2_subdev *sd)
return container_of(sd, struct thp7312_device, sd);
 }
 
+static const struct thp7312_mode_info *
+thp7312_find_mode(unsigned int width, unsigned int height, bool nearest)
+{
+   const struct thp7312_mode_info *mode;
+
+   mode = v4l2_find_nearest_size(thp7312_mode_info_data,
+ ARRAY_SIZE(thp7312_mode_info_data),
+ width, height, width, height);
+
+   if (!nearest && (mode->width != width || mode->height != height))
+   return NULL;
+
+   return mode;
+}
+
+static const struct thp7312_frame_rate *
+thp7312_find_rate(const struct thp7312_mode_info *mode, unsigned int fps,
+ bool nearest)
+{
+   const struct thp7312_frame_rate *best_rate = NULL;
+   const struct thp7312_frame_rate *rate;
+   unsigned int best_delta = UINT_MAX;
+
+   if (!mode)
+   return NULL;
+
+   for (rate = mode->rates; rate->fps && best_delta; ++rate) {
+   unsigned int delta = abs(rate->fps - fps);
+
+   if (delta <= best_delta) {
+   best_delta = delta;
+   best_rate = rate;
+   }
+   }
+
+   if (!nearest && best_delta)
+   return NULL;
+
+   return best_rate;
+}
+
 /* 
-
  * Device Access & Configuration
  */
@@ -442,17 +480,30 @@ static int thp7312_set_framefmt(struct thp7312_device 
*thp7312,
 static int thp7312_init_mode(struct thp7312_device *thp7312,
 struct v4l2_subdev_state *sd_state)
 {
+   const struct thp7312_mode_info *mode;
+   const struct thp7312_frame_rate *rate;
struct v4l2_mbus_framefmt *fmt;
+   struct v4l2_fract *interval;
int ret;
 
+   /*
+* TODO: The mode and rate should be cached in the subdev state, once
+* support for extending states will be available.
+*/
fmt = v4l2_subdev_state_get_format(sd_state, 0);
+   interval = v4l2_subdev_state_get_interval(sd_state, 0);
+
+   mode = thp7312_find_mode(fmt->width, fmt->height, false);
+   rate = thp7312_find_rate(mode, interval->denominator, false);
+
+   if (WARN_ON(!mode || !rate))
+   return -EINVAL;
 
ret = thp7312_set_framefmt(thp7312, fmt);
if (ret)
return ret;
 
-   return thp7312_change_mode(thp7312, thp7312->current_mode,
-  thp7312->current_rate);
+   return thp7312_change_mode(thp7312, mode, rate);
 }
 
 static int thp7312_stream_enable(struct thp7312_device *thp7312, bool enable)
@@ -621,28 +672,6 @@ static bool thp7312_find_bus_code(u32 code)
return false;
 }
 
-static const struct thp7312_mode_info *
-thp7312_find_mode(unsigned int width, unsigned int height, bool nearest)
-{
-   const struct thp7312_mode_info *mode;
-
-   mode = v4l2_find_nearest_size(thp7312_mode_info_data,
- ARRAY_SIZE(thp7312_mode_info_data),
- width, height, width, height);
-
-   if (!nearest && (mode->width != width || mode->height != height))
-   return NULL;
-
-   return mode;
-}
-
-static void thp7312_set_frame_rate(struct thp7312_device *thp7312,
-  const struct thp7312_frame_rate *rate)
-{
-   thp7312->link_freq = rate->link_freq;
-   thp7312->current_rate = rate;
-}
-
 static int thp7312_enum_mbus_code(struct v4l2_subdev *sd,
  struct v4l2_subdev_state *sd_state,
  struct v4l2_subdev_mbus_code_enum *code)
@@ -707,6 +736,7 @@ stati

[git:media_stage/master] media: v4l: subdev: Move out subdev state lock macros outside CONFIG_MEDIA_CONTROLLER

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: v4l: subdev: Move out subdev state lock macros outside 
CONFIG_MEDIA_CONTROLLER
Author:  Tomi Valkeinen 
Date:Wed Dec 13 17:00:03 2023 +0200

The subdev state locking macros and macros to get the active state are
currently behind CONFIG_MEDIA_CONTROLLER. This makes sense, as there can
be no subdev state without MC.

However, we have code paths common to MC and non-MC cases which call
subdev operations that have subdev state as a parameter. In the non-MC
case the state parameter would always be NULL.

Thus it makes sense to allow, e.g.:

v4l2_subdev_call_state_active(sd, pad, get_fmt, fmt)

which for non-MC case would call the subdev passing NULL as the state.

This currently fails:
https://lore.kernel.org/oe-kbuild-all/202312061101.plrz5nnj-...@intel.com/

Fix the issue by moving the related macros to be outside
CONFIG_MEDIA_CONTROLLER. The v4l2_subdev_lock_state() and
v4l2_subdev_unlock_state() macros will crash if given NULL as the state,
but the other macros behave correctly even when there's no active state,
and they will only call the lock/unlock macros if there is a state.

An alternative fix would be to make another version of
v4l2_subdev_call_state_try() with ifdefs, which would not use any state
macros and would always pass NULL as the state. But having two version
of a macro/function is always more confusing than having just one, so I
went this way.

So, this fixes the v4l2_subdev_call_state_active() macro. But we also
have v4l2_subdev_call_state_try(). It would be possible to fix that
macro by additionally creating "no-op" variants of the state alloc and
free functions. However, v4l2_subdev_call_state_try() is only used by a
single driver (stm32-dcmi), which selects MC, and the macro is supposed
to be removed as soon as the users have been converted away from the
macro. Thus I have not touched the state alloc/free functions, and I
think it makes sense to keep alloc/free functions available only if
there's actually something that can be allocated or freed.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
Link: 
https://lore.kernel.org/r/20231208-v4l2-state-mc-fix-v1-1-a0c816255...@ideasonboard.com
Signed-off-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 include/media/v4l2-subdev.h | 166 ++--
 1 file changed, 83 insertions(+), 83 deletions(-)

---

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 8b08f6640dee..61024a74ce38 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -1311,89 +1311,6 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, 
const char *name,
  */
 void v4l2_subdev_cleanup(struct v4l2_subdev *sd);
 
-/**
- * v4l2_subdev_lock_state() - Locks the subdev state
- * @state: The subdevice state
- *
- * Locks the given subdev state.
- *
- * The state must be unlocked with v4l2_subdev_unlock_state() after use.
- */
-static inline void v4l2_subdev_lock_state(struct v4l2_subdev_state *state)
-{
-   mutex_lock(state->lock);
-}
-
-/**
- * v4l2_subdev_unlock_state() - Unlocks the subdev state
- * @state: The subdevice state
- *
- * Unlocks the given subdev state.
- */
-static inline void v4l2_subdev_unlock_state(struct v4l2_subdev_state *state)
-{
-   mutex_unlock(state->lock);
-}
-
-/**
- * v4l2_subdev_get_unlocked_active_state() - Checks that the active subdev 
state
- *  is unlocked and returns it
- * @sd: The subdevice
- *
- * Returns the active state for the subdevice, or NULL if the subdev does not
- * support active state. If the state is not NULL, calls
- * lockdep_assert_not_held() to issue a warning if the state is locked.
- *
- * This function is to be used e.g. when getting the active state for the sole
- * purpose of passing it forward, without accessing the state fields.
- */
-static inline struct v4l2_subdev_state *
-v4l2_subdev_get_unlocked_active_state(struct v4l2_subdev *sd)
-{
-   if (sd->active_state)
-   lockdep_assert_not_held(sd->active_state->lock);
-   return sd->active_state;
-}
-
-/**
- * v4l2_subdev_get_locked_active_state() - Checks that the active subdev state
- *is locked and returns it
- *
- * @sd: The subdevice
- *
- * Returns the active state for the subdevice, or NULL if the subdev does not
- * support active state. If the state is not NULL, calls lockdep_assert_held()
- * to issue a warning if the state is not locked.
- *
- * This function is to be used when the caller knows that the active state is
- * already locked.
- */
-static inline struct v4l2_subdev_state *
-v4l2_subdev_get_locked_active_state(struct v4l2_subdev *sd)
-{
-   if (sd->active_state)
-   lockdep_assert_held(sd->active_state->l

[git:media_stage/master] media: v4l2-subdev: Store frame interval in subdev state

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: v4l2-subdev: Store frame interval in subdev state
Author:  Laurent Pinchart 
Date:Wed Dec 13 17:00:06 2023 +0200

Subdev states store all standard pad configuration data, except for
frame intervals. Fix it by adding interval fields in the
v4l2_subdev_pad_config and v4l2_subdev_stream_config structures, with
corresponding accessor functions and a helper function to implement the
.get_frame_interval() operation.

Signed-off-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 drivers/media/v4l2-core/v4l2-subdev.c | 52 +++
 include/media/v4l2-subdev.h   | 43 +
 2 files changed, 95 insertions(+)

---

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index 30131a37f2d5..4c6198c48dd6 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1652,6 +1652,42 @@ __v4l2_subdev_state_get_compose(struct v4l2_subdev_state 
*state,
 }
 EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_compose);
 
+struct v4l2_fract *
+__v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
+unsigned int pad, u32 stream)
+{
+   struct v4l2_subdev_stream_configs *stream_configs;
+   unsigned int i;
+
+   if (WARN_ON(!state))
+   return NULL;
+
+   lockdep_assert_held(state->lock);
+
+   if (state->pads) {
+   if (stream)
+   return NULL;
+
+   if (pad >= state->sd->entity.num_pads)
+   return NULL;
+
+   return >pads[pad].interval;
+   }
+
+   lockdep_assert_held(state->lock);
+
+   stream_configs = >stream_configs;
+
+   for (i = 0; i < stream_configs->num_configs; ++i) {
+   if (stream_configs->configs[i].pad == pad &&
+   stream_configs->configs[i].stream == stream)
+   return _configs->configs[i].interval;
+   }
+
+   return NULL;
+}
+EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_interval);
+
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
 
 static int
@@ -1718,6 +1754,22 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct 
v4l2_subdev_state *state,
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt);
 
+int v4l2_subdev_get_frame_interval(struct v4l2_subdev *sd,
+  struct v4l2_subdev_state *state,
+  struct v4l2_subdev_frame_interval *fi)
+{
+   struct v4l2_fract *interval;
+
+   interval = v4l2_subdev_state_get_interval(state, fi->pad, fi->stream);
+   if (!interval)
+   return -EINVAL;
+
+   fi->interval = *interval;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_get_frame_interval);
+
 int v4l2_subdev_set_routing(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
const struct v4l2_subdev_krouting *routing)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 0ab7dce098e6..a9e6b8146279 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -681,11 +681,13 @@ struct v4l2_subdev_ir_ops {
  * @format:  v4l2_mbus_framefmt
  * @crop:  v4l2_rect to be used for crop
  * @compose:  v4l2_rect to be used for compose
+ * @interval: frame interval
  */
 struct v4l2_subdev_pad_config {
struct v4l2_mbus_framefmt format;
struct v4l2_rect crop;
struct v4l2_rect compose;
+   struct v4l2_fract interval;
 };
 
 /**
@@ -697,6 +699,7 @@ struct v4l2_subdev_pad_config {
  * @fmt:  v4l2_mbus_framefmt
  * @crop:  v4l2_rect to be used for crop
  * @compose:  v4l2_rect to be used for compose
+ * @interval: frame interval
  *
  * This structure stores configuration for a stream.
  */
@@ -708,6 +711,7 @@ struct v4l2_subdev_stream_config {
struct v4l2_mbus_framefmt fmt;
struct v4l2_rect crop;
struct v4l2_rect compose;
+   struct v4l2_fract interval;
 };
 
 /**
@@ -1392,6 +1396,27 @@ struct v4l2_rect *
 __v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
unsigned int pad, u32 stream);
 
+/**
+ * v4l2_subdev_state_get_interval() - Get pointer to a stream frame interval
+ * @state: subdevice state
+ * @pad: pad id
+ * @...: stream id (optional argument)
+ *
+ * This returns a pointer to the frame interval for the given pad + stream in
+ * the subdev state.
+ *
+ * For stream-unaware drivers the frame interval for the corresponding pad is
+ * returned. If the pad does not exist, NULL is returned.
+ */
+#define v4l2_subdev_state_get_interval(state, pad, ...)
\
+   __v4l2_subdev_state_gen_call(interval, ##__VA_ARGS__, , _pad)   \
+   (state, pad, ##__VA_ARGS__)
+#define __v4l2_subdev_state_get_interval_pad(stat

[git:media_stage/master] media: docs: uAPI: Fix documentation of 'which' field for routing ioctls

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: docs: uAPI: Fix documentation of 'which' field for routing 
ioctls
Author:  Laurent Pinchart 
Date:Wed Dec 13 17:00:09 2023 +0200

The routing ioctls documentation incorrectly describes the 'which'
field, due to a bad copy & paste. Fix it.

Fixes: ea73eda50813 ("media: Documentation: Add GS_ROUTING documentation")
Signed-off-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
index 791c1e628d5c..26b5004bfe6d 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
@@ -72,7 +72,7 @@ On a successful ``VIDIOC_SUBDEV_G_ROUTING`` call the driver 
updates the
 
 * - __u32
   - ``which``
-  - Format to modified, from enum
+  - Routing table to be accessed, from enum
 :ref:`v4l2_subdev_format_whence `.
 * - struct :c:type:`v4l2_subdev_route`
   - ``routes[]``

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: v4l2-subdev: Turn .[gs]_frame_interval into pad operations

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: v4l2-subdev: Turn .[gs]_frame_interval into pad operations
Author:  Laurent Pinchart 
Date:Wed Dec 13 17:00:04 2023 +0200

The subdev .[gs]_frame_interval are video operations, but they operate
on pads (and even on streams). Not only is this confusing, it causes
practical issues for drivers as the operations don't receive a subdev
state pointer, requiring manual state handling.

To improve the situation, turn the operations into pad operations, and
extend them to receive a state pointer like other pad operations.

While at it, rename the operations to .[gs]et_frame_interval at the same
time to match the naming scheme of other pad operations. This isn't
strictly necessary, but given that all drivers using those operations
need to be modified, handling the rename separately would generate more
churn for very little gain (if at all).

Signed-off-by: Laurent Pinchart 
Reviewed-by: Hans Verkuil 
Reviewed-by: Philipp Zabel  # for imx-media
Reviewed-by: Luca Ceresoli  # for tegra-video
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/adv7180.c|  7 +--
 drivers/media/i2c/alvium-csi2.c| 11 ++--
 drivers/media/i2c/et8ek8/et8ek8_driver.c   |  6 ++-
 drivers/media/i2c/imx214.c |  9 ++--
 drivers/media/i2c/imx274.c | 48 ++---
 drivers/media/i2c/max9286.c| 14 ++---
 drivers/media/i2c/mt9m111.c| 14 ++---
 drivers/media/i2c/mt9m114.c| 14 ++---
 drivers/media/i2c/mt9v011.c| 18 +++
 drivers/media/i2c/mt9v111.c| 16 +++---
 drivers/media/i2c/ov2680.c |  7 +--
 drivers/media/i2c/ov5640.c | 16 +++---
 drivers/media/i2c/ov5648.c | 59 ++--
 drivers/media/i2c/ov5693.c |  7 +--
 drivers/media/i2c/ov6650.c | 16 +++---
 drivers/media/i2c/ov7251.c |  6 ++-
 drivers/media/i2c/ov7670.c | 18 +++
 drivers/media/i2c/ov772x.c | 14 ++---
 drivers/media/i2c/ov7740.c | 40 +-
 drivers/media/i2c/ov8865.c | 51 +-
 drivers/media/i2c/ov9650.c | 14 ++---
 drivers/media/i2c/s5c73m3/s5c73m3-core.c   | 14 ++---
 drivers/media/i2c/s5k5baf.c| 20 +++
 drivers/media/i2c/thp7312.c| 22 +++-
 drivers/media/i2c/tvp514x.c| 29 +++---
 drivers/media/usb/em28xx/em28xx-video.c|  6 ++-
 drivers/media/v4l2-core/v4l2-common.c  |  8 +--
 drivers/media/v4l2-core/v4l2-subdev.c  | 63 --
 drivers/staging/media/atomisp/i2c/atomisp-gc0310.c |  7 +--
 drivers/staging/media/atomisp/i2c/atomisp-gc2235.c |  7 +--
 .../staging/media/atomisp/i2c/atomisp-mt9m114.c|  7 +--
 drivers/staging/media/atomisp/i2c/atomisp-ov2722.c |  7 +--
 drivers/staging/media/atomisp/pci/atomisp_cmd.c|  4 +-
 drivers/staging/media/atomisp/pci/atomisp_ioctl.c  |  4 +-
 drivers/staging/media/imx/imx-ic-prp.c | 14 ++---
 drivers/staging/media/imx/imx-ic-prpencvf.c| 14 ++---
 drivers/staging/media/imx/imx-media-capture.c  |  6 ++-
 drivers/staging/media/imx/imx-media-csi.c  | 14 ++---
 drivers/staging/media/imx/imx-media-vdic.c | 14 ++---
 drivers/staging/media/tegra-video/csi.c|  9 ++--
 include/media/v4l2-common.h|  4 +-
 include/media/v4l2-subdev.h| 22 
 42 files changed, 352 insertions(+), 348 deletions(-)

---

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index e10811cce801..7ed86030fb5c 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -463,8 +463,9 @@ static int adv7180_g_std(struct v4l2_subdev *sd, 
v4l2_std_id *norm)
return 0;
 }
 
-static int adv7180_g_frame_interval(struct v4l2_subdev *sd,
-   struct v4l2_subdev_frame_interval *fi)
+static int adv7180_get_frame_interval(struct v4l2_subdev *sd,
+ struct v4l2_subdev_state *sd_state,
+ struct v4l2_subdev_frame_interval *fi)
 {
struct adv7180_state *state = to_state(sd);
 
@@ -913,7 +914,6 @@ static int adv7180_subscribe_event(struct v4l2_subdev *sd,
 static const struct v4l2_subdev_video_ops adv7180_video_ops = {
.s_std = adv7180_s_std,
.g_std = adv7180_g_std,
-   .g_frame_interval = adv7180_g_frame_interval,
.querystd = adv7180_querystd,
.g_input_status = adv7180_g_input_status,
.s_routing = adv7180_s_routing,
@@ -932,6 +932,7

[git:media_stage/master] media: docs: uAPI: Clarify error documentation for invalid 'which' value

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: docs: uAPI: Clarify error documentation for invalid 'which' 
value
Author:  Laurent Pinchart 
Date:Wed Dec 13 17:00:07 2023 +0200

Invalid values for the 'which' field of structures passed to multiple
subdev ioctls result in an EINVAL error being returned. The
documentation of the corresponding ioctls indicates this with sentences
such as the following:

the ``which`` field references a non-existing format

This is confusing. Clarify the documentation.

Suggested-by: Hans Verkuil 
Signed-off-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 Documentation/userspace-api/media/v4l/vidioc-subdev-g-crop.rst | 7 +++
 Documentation/userspace-api/media/v4l/vidioc-subdev-g-fmt.rst  | 5 ++---
 .../userspace-api/media/v4l/vidioc-subdev-g-frame-interval.rst | 7 +++
 .../userspace-api/media/v4l/vidioc-subdev-g-selection.rst  | 7 +++
 4 files changed, 11 insertions(+), 15 deletions(-)

---

diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-crop.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-crop.rst
index 1d267f7e7991..92d933631fda 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-crop.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-crop.rst
@@ -118,10 +118,9 @@ EBUSY
 ``VIDIOC_SUBDEV_S_CROP``
 
 EINVAL
-The struct :c:type:`v4l2_subdev_crop` ``pad``
-references a non-existing pad, the ``which`` field references a
-non-existing format, or cropping is not supported on the given
-subdev pad.
+The struct :c:type:`v4l2_subdev_crop` ``pad`` references a non-existing 
pad,
+the ``which`` field has an unsupported value, or cropping is not supported
+on the given subdev pad.
 
 EPERM
 The ``VIDIOC_SUBDEV_S_CROP`` ioctl has been called on a read-only subdevice
diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-fmt.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-fmt.rst
index ed253a1e44b7..4a2b4e4f0152 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-fmt.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-fmt.rst
@@ -140,9 +140,8 @@ EBUSY
 fix the problem first. Only returned by ``VIDIOC_SUBDEV_S_FMT``
 
 EINVAL
-The struct :c:type:`v4l2_subdev_format`
-``pad`` references a non-existing pad, or the ``which`` field
-references a non-existing format.
+The struct :c:type:`v4l2_subdev_format` ``pad`` references a non-existing
+pad, or the ``which`` field has an unsupported value.
 
 EPERM
 The ``VIDIOC_SUBDEV_S_FMT`` ioctl has been called on a read-only subdevice
diff --git 
a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-frame-interval.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-frame-interval.rst
index 41e0e2c8ecc3..c8022809ac35 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-frame-interval.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-frame-interval.rst
@@ -117,10 +117,9 @@ EBUSY
 ``VIDIOC_SUBDEV_S_FRAME_INTERVAL``
 
 EINVAL
-The struct
-:c:type:`v4l2_subdev_frame_interval`
-``pad`` references a non-existing pad, the ``which`` field references a
-non-existing frame interval, or the pad doesn't support frame intervals.
+The struct :c:type:`v4l2_subdev_frame_interval` ``pad`` references a
+non-existing pad, the ``which`` field has an unsupported value, or the pad
+doesn't support frame intervals.
 
 EPERM
 The ``VIDIOC_SUBDEV_S_FRAME_INTERVAL`` ioctl has been called on a read-only
diff --git 
a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-selection.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-selection.rst
index 6b629c19168c..19e6c3e9c06d 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-selection.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-selection.rst
@@ -116,10 +116,9 @@ EBUSY
 ``VIDIOC_SUBDEV_S_SELECTION``
 
 EINVAL
-The struct :c:type:`v4l2_subdev_selection`
-``pad`` references a non-existing pad, the ``which`` field
-references a non-existing format, or the selection target is not
-supported on the given subdev pad.
+The struct :c:type:`v4l2_subdev_selection` ``pad`` references a
+non-existing pad, the ``which`` field has an unsupported value, or the
+selection target is not supported on the given subdev pad.
 
 EPERM
 The ``VIDIOC_SUBDEV_S_SELECTION`` ioctl has been called on a read-only

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: v4l2-subdev: Add which field to struct v4l2_subdev_frame_interval

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: v4l2-subdev: Add which field to struct 
v4l2_subdev_frame_interval
Author:  Laurent Pinchart 
Date:Wed Dec 13 17:00:05 2023 +0200

Due to a historical mishap, the v4l2_subdev_frame_interval structure
is the only part of the V4L2 subdev userspace API that doesn't contain a
'which' field. This prevents trying frame intervals using the subdev
'TRY' state mechanism.

Adding a 'which' field is simple as the structure has 8 reserved fields.
This would however break userspace as the field is currently set to 0,
corresponding to V4L2_SUBDEV_FORMAT_TRY, while the corresponding ioctls
currently operate on the 'ACTIVE' state. We thus need to add a new
subdev client cap, V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH, to
indicate that userspace is aware of this new field.

All drivers that implement the subdev .get_frame_interval() and
.set_frame_interval() operations are updated to return -EINVAL when
operating on the TRY state, preserving the current behaviour.

While at it, fix a bad copy in the documentation of the struct
v4l2_subdev_frame_interval_enum 'which' field.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Philipp Zabel  # for imx-media
Reviewed-by: Hans Verkuil 
Reviewed-by: Luca Ceresoli  # for tegra-video
Reviewed-by: Mauro Carvalho Chehab 
Signed-off-by: Hans Verkuil 

 .../media/v4l/vidioc-subdev-g-client-cap.rst   |  5 +
 .../media/v4l/vidioc-subdev-g-frame-interval.rst   | 17 +--
 drivers/media/i2c/adv7180.c|  7 ++
 drivers/media/i2c/alvium-csi2.c| 14 
 drivers/media/i2c/et8ek8/et8ek8_driver.c   | 14 
 drivers/media/i2c/imx214.c |  7 ++
 drivers/media/i2c/imx274.c | 14 
 drivers/media/i2c/max9286.c| 14 
 drivers/media/i2c/mt9m111.c| 14 
 drivers/media/i2c/mt9m114.c| 14 
 drivers/media/i2c/mt9v011.c| 14 
 drivers/media/i2c/mt9v111.c| 14 
 drivers/media/i2c/ov2680.c |  7 ++
 drivers/media/i2c/ov5640.c | 14 
 drivers/media/i2c/ov5648.c |  7 ++
 drivers/media/i2c/ov5693.c |  7 ++
 drivers/media/i2c/ov6650.c | 14 
 drivers/media/i2c/ov7251.c | 14 
 drivers/media/i2c/ov7670.c | 12 +++
 drivers/media/i2c/ov772x.c | 14 
 drivers/media/i2c/ov8865.c |  7 ++
 drivers/media/i2c/ov9650.c | 14 
 drivers/media/i2c/s5c73m3/s5c73m3-core.c   | 14 
 drivers/media/i2c/s5k5baf.c| 14 
 drivers/media/i2c/thp7312.c| 14 
 drivers/media/i2c/tvp514x.c| 12 +++
 drivers/media/v4l2-core/v4l2-subdev.c  | 25 ++
 drivers/staging/media/atomisp/i2c/atomisp-gc0310.c |  7 ++
 drivers/staging/media/atomisp/i2c/atomisp-gc2235.c |  7 ++
 .../staging/media/atomisp/i2c/atomisp-mt9m114.c|  7 ++
 drivers/staging/media/atomisp/i2c/atomisp-ov2722.c |  7 ++
 drivers/staging/media/imx/imx-ic-prp.c | 14 
 drivers/staging/media/imx/imx-ic-prpencvf.c| 14 
 drivers/staging/media/imx/imx-media-csi.c  | 14 
 drivers/staging/media/imx/imx-media-vdic.c | 14 
 drivers/staging/media/tegra-video/csi.c|  7 ++
 include/uapi/linux/v4l2-subdev.h   | 15 ++---
 37 files changed, 425 insertions(+), 18 deletions(-)

---

diff --git 
a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
index 20f12a1cc0f7..810b6a859dc8 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-client-cap.rst
@@ -71,6 +71,11 @@ is unknown to the kernel.
 of 'stream' fields (referring to the stream number) with various
 ioctls. If this is not set (which is the default), the 'stream' fields
 will be forced to 0 by the kernel.
+* - ``V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH``
+  - The client is aware of the :c:type:`v4l2_subdev_frame_interval`
+``which`` field. If this is not set (which is the default), the
+``which`` field is forced to ``V4L2_SUBDEV_FORMAT_ACTIVE`` by the
+kernel.
 
 Return Value
 
diff --git 
a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-frame-interval.rst 
b

[git:media_stage/master] media: docs: uAPI: Expand error documentation for invalid 'which' value

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: docs: uAPI: Expand error documentation for invalid 'which' value
Author:  Laurent Pinchart 
Date:Wed Dec 13 17:00:08 2023 +0200

Multiple subdev ioctls that take a 'which' field do not document the
error returned when the field has an invalid value. Expand the
documentation to fix this.

Signed-off-by: Laurent Pinchart 
Signed-off-by: Hans Verkuil 

 .../media/v4l/vidioc-subdev-enum-frame-interval.rst  | 9 -
 .../userspace-api/media/v4l/vidioc-subdev-enum-frame-size.rst| 7 +++
 .../userspace-api/media/v4l/vidioc-subdev-enum-mbus-code.rst | 7 +++
 .../userspace-api/media/v4l/vidioc-subdev-g-routing.rst  | 5 +++--
 4 files changed, 13 insertions(+), 15 deletions(-)

---

diff --git 
a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-interval.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-interval.rst
index 8def4c05d3da..c935bacc3bc2 100644
--- 
a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-interval.rst
+++ 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-interval.rst
@@ -107,8 +107,7 @@ appropriately. The generic error codes are described at the
 :ref:`Generic Error Codes ` chapter.
 
 EINVAL
-The struct
-:c:type:`v4l2_subdev_frame_interval_enum`
-``pad`` references a non-existing pad, one of the ``code``,
-``width`` or ``height`` fields are invalid for the given pad or the
-``index`` field is out of bounds.
+The struct :c:type:`v4l2_subdev_frame_interval_enum` ``pad`` references a
+non-existing pad, the ``which`` field has an unsupported value, one of the
+``code``, ``width`` or ``height`` fields are invalid for the given pad, or
+the ``index`` field is out of bounds.
diff --git 
a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-size.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-size.rst
index e3ae84df5486..65f0cfeca973 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-size.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-frame-size.rst
@@ -126,7 +126,6 @@ appropriately. The generic error codes are described at the
 :ref:`Generic Error Codes ` chapter.
 
 EINVAL
-The struct
-:c:type:`v4l2_subdev_frame_size_enum`
-``pad`` references a non-existing pad, the ``code`` is invalid for
-the given pad or the ``index`` field is out of bounds.
+The struct :c:type:`v4l2_subdev_frame_size_enum` ``pad`` references a
+non-existing pad, the ``which`` field has an unsupported value, the 
``code``
+is invalid for the given pad, or the ``index`` field is out of bounds.
diff --git 
a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-mbus-code.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-mbus-code.rst
index 4ad7dec27e25..3050966b199f 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-mbus-code.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-enum-mbus-code.rst
@@ -158,7 +158,6 @@ appropriately. The generic error codes are described at the
 :ref:`Generic Error Codes ` chapter.
 
 EINVAL
-The struct
-:c:type:`v4l2_subdev_mbus_code_enum`
-``pad`` references a non-existing pad, or the ``index`` field is out
-of bounds.
+The struct :c:type:`v4l2_subdev_mbus_code_enum` ``pad`` references a
+non-existing pad, the ``which`` field has an unsupported value, or the
+``index`` field is out of bounds.
diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst 
b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
index 72677a280cd6..791c1e628d5c 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
@@ -140,8 +140,9 @@ ENOSPC
all the available routes the subdevice exposes.
 
 EINVAL
-   The sink or source pad identifiers reference a non-existing pad, or 
reference
-   pads of different types (ie. the sink_pad identifiers refers to a source 
pad).
+   The sink or source pad identifiers reference a non-existing pad or reference
+   pads of different types (ie. the sink_pad identifiers refers to a source
+   pad), or the ``which`` field has an unsupported value.
 
 E2BIG
The application provided ``num_routes`` for ``VIDIOC_SUBDEV_S_ROUTING`` is

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: s5p-mfc: Add initial support for MFCv12

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s5p-mfc: Add initial support for MFCv12
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:40:58 2023 +0530

Add support for MFCv12, with a new register file and necessary hw
control, decoder, encoder and structural changes. Add luma dbp, chroma
dpb and mv sizes for each codec as per the UM for MFCv12, along with
appropriate alignment.

Cc: linux-...@tesla.com
Signed-off-by: Smitha T Murthy 
Signed-off-by: Aakarsh Jain 
Signed-off-by: Hans Verkuil 

 .../media/platform/samsung/s5p-mfc/regs-mfc-v12.h  | 50 +
 drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c   | 30 
 .../platform/samsung/s5p-mfc/s5p_mfc_common.h  | 17 +++--
 .../media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c  |  2 +-
 .../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c   |  6 +-
 .../media/platform/samsung/s5p-mfc/s5p_mfc_enc.c   |  5 +-
 .../media/platform/samsung/s5p-mfc/s5p_mfc_opr.h   |  8 +--
 .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c  | 83 +-
 .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h  |  6 +-
 9 files changed, 172 insertions(+), 35 deletions(-)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v12.h 
b/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v12.h
new file mode 100644
index ..d987bba1ffbd
--- /dev/null
+++ b/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v12.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Register definition file for Samsung MFC V12.x Interface (FIMV) driver
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/
+ */
+
+#ifndef _REGS_MFC_V12_H
+#define _REGS_MFC_V12_H
+
+#include 
+#include "regs-mfc-v10.h"
+
+/* MFCv12 Context buffer sizes */
+#define MFC_CTX_BUF_SIZE_V12   (30 * SZ_1K)
+#define MFC_H264_DEC_CTX_BUF_SIZE_V12  (2 * SZ_1M)
+#define MFC_OTHER_DEC_CTX_BUF_SIZE_V12 (30 * SZ_1K)
+#define MFC_H264_ENC_CTX_BUF_SIZE_V12  (100 * SZ_1K)
+#define MFC_HEVC_ENC_CTX_BUF_SIZE_V12  (40 * SZ_1K)
+#define MFC_OTHER_ENC_CTX_BUF_SIZE_V12 (25 * SZ_1K)
+
+/* MFCv12 variant defines */
+#define MAX_FW_SIZE_V12(SZ_1M)
+#define MAX_CPB_SIZE_V12   (7 * SZ_1M)
+#define MFC_VERSION_V120xC0
+#define MFC_NUM_PORTS_V12  1
+#define S5P_FIMV_CODEC_VP9_ENC 27
+
+/* Encoder buffer size for MFCv12 */
+#define ENC_V120_BASE_SIZE(x, y) \
+   x) + 3) * ((y) + 3) * 8) \
+   + y) * 64) + 2304) * ((x) + 7) / 8))
+
+#define ENC_V120_H264_ME_SIZE(x, y) \
+   ALIGN((ENC_V120_BASE_SIZE(x, y) \
+   + (DIV_ROUND_UP((x) * (y), 64) * 32)), 256)
+
+#define ENC_V120_MPEG4_ME_SIZE(x, y) \
+   ALIGN((ENC_V120_BASE_SIZE(x, y) \
+   + (DIV_ROUND_UP((x) * (y), 128) * 16)), 256)
+
+#define ENC_V120_VP8_ME_SIZE(x, y) \
+   ALIGN(ENC_V120_BASE_SIZE((x), (y)), 256)
+
+#define ENC_V120_HEVC_ME_SIZE(x, y) \
+   ALIGN(x) + 3) * ((y) + 3) * 32)   \
+   + y) * 128) + 2304) * ((x) + 3) / 4)), 256)
+
+#endif /*_REGS_MFC_V12_H*/
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index e30e54935d79..dee9ef017997 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -790,6 +790,8 @@ static int s5p_mfc_open(struct file *file)
INIT_LIST_HEAD(>dst_queue);
ctx->src_queue_cnt = 0;
ctx->dst_queue_cnt = 0;
+   ctx->is_422 = 0;
+   ctx->is_10bit = 0;
/* Get context number */
ctx->num = 0;
while (dev->ctx[ctx->num]) {
@@ -1660,6 +1662,31 @@ static struct s5p_mfc_variant mfc_drvdata_v10 = {
.fw_name[0] = "s5p-mfc-v10.fw",
 };
 
+static struct s5p_mfc_buf_size_v6 mfc_buf_size_v12 = {
+   .dev_ctx= MFC_CTX_BUF_SIZE_V12,
+   .h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V12,
+   .other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V12,
+   .h264_enc_ctx   = MFC_H264_ENC_CTX_BUF_SIZE_V12,
+   .hevc_enc_ctx   = MFC_HEVC_ENC_CTX_BUF_SIZE_V12,
+   .other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V12,
+};
+
+static struct s5p_mfc_buf_size buf_size_v12 = {
+   .fw = MAX_FW_SIZE_V12,
+   .cpb= MAX_CPB_SIZE_V12,
+   .priv   = _buf_size_v12,
+};
+
+static struct s5p_mfc_variant mfc_drvdata_v12 = {
+   .version= MFC_VERSION_V12,
+   .version_bit= MFC_V12_BIT,
+   .port_num   = MFC_NUM_PORTS_V12,
+   .buf_size   = _size_v12,
+   .fw_name[0] = "s5p-mfc-v12.fw",
+   .clk_names  = {"mfc"},
+   .num_clocks = 1,
+};
+
 static const struct of_device_id exynos_mfc_match[] = {
{
.compatible = "samsung,mfc-v5",
@@ -1682,6 +1709,9 @@ static const struct of_device_id exynos_mfc_match[] = {
}, {
   

[git:media_stage/master] media: s5p-mfc: Set context for valid case before calling try_run

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s5p-mfc: Set context for valid case before calling try_run
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:41:03 2023 +0530

Context bit is set for hardware execution if there is a buffer in
source and destination queue before calling try_run in the
init_buffers function. Now there will be a new context created and
hardware will be invoked for the buffer queued instead of waiting for
another buffer to be queued from userspace to set this context bit for
hw execution.

Cc: linux-...@tesla.com
Signed-off-by: Smitha T Murthy 
Signed-off-by: Aakarsh Jain 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 2 ++
 1 file changed, 2 insertions(+)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index bd055dea827e..fbb047eadf5a 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -604,6 +604,8 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx 
*ctx,
s5p_mfc_clock_off();
 
wake_up(>queue);
+   if (ctx->src_queue_cnt >= 1 && ctx->dst_queue_cnt >= 1)
+   set_work_bit_irqsave(ctx);
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
} else {
WARN_ON(test_and_clear_bit(0, >hw_lock) == 0);

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: s5p-mfc: Load firmware for each run in MFCv12.

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s5p-mfc: Load firmware for each run in MFCv12.
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:41:04 2023 +0530

In MFCv12, some section of firmware gets updated at each MFC run.
Hence we need to reload original firmware for each run at the start.

Cc: linux-...@tesla.com
Signed-off-by: Smitha T Murthy 
Signed-off-by: Aakarsh Jain 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
index b49159142c53..503487f34a80 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
@@ -51,8 +51,14 @@ int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev)
 * into kernel. */
mfc_debug_enter();
 
-   if (dev->fw_get_done)
-   return 0;
+   /* In case of MFC v12, RET_SYS_INIT response from hardware fails due to
+* incorrect firmware transfer and therefore it is not able to 
initialize
+* the hardware. This causes failed response for SYS_INIT command when
+* MFC runs for second time. So, load the MFC v12 firmware for each run.
+*/
+   if (!IS_MFCV12(dev))
+   if (dev->fw_get_done)
+   return 0;
 
for (i = MFC_FW_MAX_VERSIONS - 1; i >= 0; i--) {
if (!dev->variant->fw_name[i])

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: s5p-mfc: DPB Count Independent of VIDIOC_REQBUF

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s5p-mfc: DPB Count Independent of VIDIOC_REQBUF
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:41:05 2023 +0530

Add allocation of DPB buffers based on MFC requirement so,
codec buffers allocations has been moved after state
MFCINST_HEAD_PRODUCED. It is taken care that codec buffer allocation
is performed in process context from userspace IOCTL call.

Cc: linux-...@tesla.com
Signed-off-by: Smitha T Murthy 
Signed-off-by: Aakarsh Jain 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c   | 18 ++
 .../media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c|  7 +++
 2 files changed, 9 insertions(+), 16 deletions(-)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
index ae3764969473..ef8bb40b9712 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -1164,7 +1164,6 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_enc_params *p = >enc_params;
struct s5p_mfc_buf *dst_mb;
-   unsigned int enc_pb_count;
 
if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) {
if (!list_empty(>dst_queue)) {
@@ -1186,10 +1185,7 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
set_work_bit_irqsave(ctx);
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
} else {
-   enc_pb_count = s5p_mfc_hw_call(dev->mfc_ops,
-   get_enc_dpb_count, dev);
-   if (ctx->pb_count < enc_pb_count)
-   ctx->pb_count = enc_pb_count;
+   ctx->pb_count = s5p_mfc_hw_call(dev->mfc_ops, 
get_enc_dpb_count, dev);
if (FW_HAS_E_MIN_SCRATCH_BUF(dev)) {
ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops,
get_e_min_scratch_buf_size, dev);
@@ -1564,14 +1560,6 @@ static int vidioc_reqbufs(struct file *file, void *priv,
}
ctx->capture_state = QUEUE_BUFS_REQUESTED;
 
-   ret = s5p_mfc_hw_call(ctx->dev->mfc_ops,
-   alloc_codec_buffers, ctx);
-   if (ret) {
-   mfc_err("Failed to allocate encoding buffers\n");
-   reqbufs->count = 0;
-   ret = vb2_reqbufs(>vq_dst, reqbufs);
-   return -ENOMEM;
-   }
} else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
if (reqbufs->count == 0) {
mfc_debug(2, "Freeing buffers\n");
@@ -1587,15 +1575,13 @@ static int vidioc_reqbufs(struct file *file, void *priv,
return -EINVAL;
}
 
-   if (IS_MFCV6_PLUS(dev)) {
+   if (IS_MFCV6_PLUS(dev) && (!IS_MFCV12(dev))) {
/* Check for min encoder buffers */
if (ctx->pb_count &&
(reqbufs->count < ctx->pb_count)) {
reqbufs->count = ctx->pb_count;
mfc_debug(2, "Minimum %d output buffers 
needed\n",
ctx->pb_count);
-   } else {
-   ctx->pb_count = reqbufs->count;
}
}
 
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
index 572293f3b190..fd945211d28e 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
@@ -2110,6 +2110,13 @@ static inline int s5p_mfc_run_init_enc_buffers(struct 
s5p_mfc_ctx *ctx)
struct s5p_mfc_dev *dev = ctx->dev;
int ret;
 
+   ret = s5p_mfc_hw_call(ctx->dev->mfc_ops, alloc_codec_buffers, ctx);
+   if (ret) {
+   mfc_err("Failed to allocate encoding buffers\n");
+   return -ENOMEM;
+   }
+   mfc_debug(2, "Allocated Internal Encoding Buffers\n");
+
dev->curr_ctx = ctx->num;
ret = s5p_mfc_set_enc_ref_buffer_v6(ctx);
if (ret) {

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] dt-bindings: media: s5p-mfc: Add mfcv12 variant

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: dt-bindings: media: s5p-mfc: Add mfcv12 variant
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:40:56 2023 +0530

Add Tesla FSD MFC(MFC v12) compatible.

Cc: linux-...@tesla.com
Signed-off-by: Aakarsh Jain 
Reviewed-by: Krzysztof Kozlowski 
Signed-off-by: Hans Verkuil 

 .../devicetree/bindings/media/samsung,s5p-mfc.yaml | 18 ++
 1 file changed, 18 insertions(+)

---

diff --git a/Documentation/devicetree/bindings/media/samsung,s5p-mfc.yaml 
b/Documentation/devicetree/bindings/media/samsung,s5p-mfc.yaml
index 084b44582a43..d66e51547482 100644
--- a/Documentation/devicetree/bindings/media/samsung,s5p-mfc.yaml
+++ b/Documentation/devicetree/bindings/media/samsung,s5p-mfc.yaml
@@ -24,6 +24,7 @@ properties:
   - samsung,mfc-v7# Exynos5420
   - samsung,mfc-v8# Exynos5800
   - samsung,mfc-v10   # Exynos7880
+  - tesla,fsd-mfc # Tesla FSD
   - items:
   - enum:
   - samsung,exynos3250-mfc# Exynos3250
@@ -165,6 +166,23 @@ allOf:
   minItems: 1
   maxItems: 2
 
+  - if:
+  properties:
+compatible:
+  contains:
+enum:
+  - tesla,fsd-mfc
+then:
+  properties:
+clocks:
+  maxItems: 1
+clock-names:
+  items:
+- const: mfc
+iommus:
+  maxItems: 2
+iommus-names: false
+
 examples:
   - |
 #include 

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: s5p-mfc: Add support for DMABUF for encoder

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s5p-mfc: Add support for DMABUF for encoder
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:41:02 2023 +0530

Add dmabuf support for mfc encoder

Cc: linux-...@tesla.com
Signed-off-by: Smitha T Murthy 
Signed-off-by: Aakarsh Jain 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c |  4 ++--
 drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 20 +++-
 2 files changed, 13 insertions(+), 11 deletions(-)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index dee9ef017997..bd055dea827e 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -865,7 +865,7 @@ static int s5p_mfc_open(struct file *file)
q->io_modes = VB2_MMAP;
q->ops = get_dec_queue_ops();
} else if (vdev == dev->vfd_enc) {
-   q->io_modes = VB2_MMAP | VB2_USERPTR;
+   q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
q->ops = get_enc_queue_ops();
} else {
ret = -ENOENT;
@@ -892,7 +892,7 @@ static int s5p_mfc_open(struct file *file)
q->io_modes = VB2_MMAP;
q->ops = get_dec_queue_ops();
} else if (vdev == dev->vfd_enc) {
-   q->io_modes = VB2_MMAP | VB2_USERPTR;
+   q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
q->ops = get_enc_queue_ops();
} else {
ret = -ENOENT;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
index 67fe0302464f..ae3764969473 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -1538,9 +1538,10 @@ static int vidioc_reqbufs(struct file *file, void *priv,
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
int ret = 0;
 
-   /* if memory is not mmp or userptr return error */
+   /* if memory is not mmp or userptr or dmabuf return error */
if ((reqbufs->memory != V4L2_MEMORY_MMAP) &&
-   (reqbufs->memory != V4L2_MEMORY_USERPTR))
+   (reqbufs->memory != V4L2_MEMORY_USERPTR) &&
+   (reqbufs->memory != V4L2_MEMORY_DMABUF))
return -EINVAL;
if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
if (reqbufs->count == 0) {
@@ -1617,9 +1618,10 @@ static int vidioc_querybuf(struct file *file, void *priv,
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
int ret = 0;
 
-   /* if memory is not mmp or userptr return error */
+   /* if memory is not mmp or userptr or dmabuf return error */
if ((buf->memory != V4L2_MEMORY_MMAP) &&
-   (buf->memory != V4L2_MEMORY_USERPTR))
+   (buf->memory != V4L2_MEMORY_USERPTR) &&
+   (buf->memory != V4L2_MEMORY_DMABUF))
return -EINVAL;
if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
if (ctx->state != MFCINST_GOT_INST) {
@@ -2581,11 +2583,11 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, 
unsigned int count)
S5P_MFC_R2H_CMD_SEQ_DONE_RET,
0);
}
-
-   if (ctx->src_bufs_cnt < ctx->pb_count) {
-   mfc_err("Need minimum %d OUTPUT buffers\n",
-   ctx->pb_count);
-   return -ENOBUFS;
+   if (q->memory != V4L2_MEMORY_DMABUF) {
+   if (ctx->src_bufs_cnt < ctx->pb_count) {
+   mfc_err("Need minimum %d OUTPUT buffers\n", 
ctx->pb_count);
+   return -ENOBUFS;
+   }
}
}
 

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: s5p-mfc: Add YV12 and I420 multiplanar format support

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s5p-mfc: Add YV12 and I420 multiplanar format support
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:40:59 2023 +0530

YV12 and I420 format (3-plane) support is added. Stride information is
added to all formats and planes since it is necessary for YV12/I420
which are different from width.

Cc: linux-...@tesla.com
Signed-off-by: Smitha T Murthy 
Signed-off-by: Aakarsh Jain 
Signed-off-by: Hans Verkuil 

 .../media/platform/samsung/s5p-mfc/regs-mfc-v12.h  |   2 +
 .../media/platform/samsung/s5p-mfc/regs-mfc-v7.h   |   1 +
 .../media/platform/samsung/s5p-mfc/regs-mfc-v8.h   |   3 +
 .../platform/samsung/s5p-mfc/s5p_mfc_common.h  |   6 +
 .../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c   |  54 ++-
 .../media/platform/samsung/s5p-mfc/s5p_mfc_enc.c   |  98 ++---
 .../media/platform/samsung/s5p-mfc/s5p_mfc_opr.h   |   6 +-
 .../platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c  |  12 +-
 .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c  | 157 -
 9 files changed, 276 insertions(+), 63 deletions(-)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v12.h 
b/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v12.h
index d987bba1ffbd..24e669d8ea29 100644
--- a/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v12.h
+++ b/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v12.h
@@ -26,6 +26,8 @@
 #define MFC_VERSION_V120xC0
 #define MFC_NUM_PORTS_V12  1
 #define S5P_FIMV_CODEC_VP9_ENC 27
+#define MFC_CHROMA_PAD_BYTES_V12256
+#define S5P_FIMV_D_ALIGN_PLANE_SIZE_V12 256
 
 /* Encoder buffer size for MFCv12 */
 #define ENC_V120_BASE_SIZE(x, y) \
diff --git a/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v7.h 
b/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v7.h
index 4a7adfdaa359..50f9bf0603c1 100644
--- a/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v7.h
+++ b/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v7.h
@@ -24,6 +24,7 @@
 
 #define S5P_FIMV_E_ENCODED_SOURCE_FIRST_ADDR_V70xfa70
 #define S5P_FIMV_E_ENCODED_SOURCE_SECOND_ADDR_V7   0xfa74
+#define S5P_FIMV_E_ENCODED_SOURCE_THIRD_ADDR_V70xfa78
 
 #define S5P_FIMV_E_VP8_OPTIONS_V7  0xfdb0
 #define S5P_FIMV_E_VP8_FILTER_OPTIONS_V7   0xfdb4
diff --git a/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v8.h 
b/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v8.h
index 162e3c7e920f..0ef9eb2dff22 100644
--- a/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v8.h
+++ b/drivers/media/platform/samsung/s5p-mfc/regs-mfc-v8.h
@@ -17,13 +17,16 @@
 #define S5P_FIMV_D_MIN_SCRATCH_BUFFER_SIZE_V8  0xf108
 #define S5P_FIMV_D_FIRST_PLANE_DPB_SIZE_V8 0xf144
 #define S5P_FIMV_D_SECOND_PLANE_DPB_SIZE_V80xf148
+#define S5P_FIMV_D_THIRD_PLANE_DPB_SIZE_V8 0xf14C
 #define S5P_FIMV_D_MV_BUFFER_SIZE_V8   0xf150
 
 #define S5P_FIMV_D_FIRST_PLANE_DPB_STRIDE_SIZE_V8  0xf138
 #define S5P_FIMV_D_SECOND_PLANE_DPB_STRIDE_SIZE_V8 0xf13c
+#define S5P_FIMV_D_THIRD_PLANE_DPB_STRIDE_SIZE_V8  0xf140
 
 #define S5P_FIMV_D_FIRST_PLANE_DPB_V8  0xf160
 #define S5P_FIMV_D_SECOND_PLANE_DPB_V8 0xf260
+#define S5P_FIMV_D_THIRD_PLANE_DPB_V8  0xf360
 #define S5P_FIMV_D_MV_BUFFER_V80xf460
 
 #define S5P_FIMV_D_NUM_MV_V8   0xf134
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
index aa87b3404b33..59450b324f7d 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -56,6 +56,7 @@
 #define MFC_NO_INSTANCE_SET-1
 #define MFC_ENC_CAP_PLANE_COUNT1
 #define MFC_ENC_OUT_PLANE_COUNT2
+#define VB2_MAX_PLANE_COUNT3
 #define STUFF_BYTE 4
 #define MFC_MAX_CTRLS  128
 
@@ -181,6 +182,7 @@ struct s5p_mfc_buf {
struct {
size_t luma;
size_t chroma;
+   size_t chroma_1;
} raw;
size_t stream;
} cookie;
@@ -623,6 +625,8 @@ struct s5p_mfc_codec_ops {
  * @scratch_buf_size:  scratch buffer size
  * @is_10bit:  state to check 10bit support
  * @is_422:state to check YUV422 10bit format
+ * @chroma_size_1: size of a chroma third plane
+ * @stride:size of stride for all planes
  */
 struct s5p_mfc_ctx {
struct s5p_mfc_dev *dev;
@@ -659,6 +663,7 @@ struct s5p_mfc_ctx {
 
int luma_size;
int chroma_size;
+   int chroma_size_1;
int mv_size;
 
unsigned long consumed_stream;
@@ -724,6 +729,7 @@ struct s5p_mfc_ctx {
size_t scratch_buf_size;
int is_10bit;
int is_422;
+   int stride[VB2_MAX_PLANE_COUNT];
 };
 
 /*
diff --git a/drivers/media/platform/samsung

[git:media_stage/master] media: s5p-mfc: Rename IS_MFCV10 macro

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s5p-mfc: Rename IS_MFCV10 macro
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:40:57 2023 +0530

Renames macro IS_MFCV10 to IS_MFCV10_PLUS so that the MFCv10 code can
be resued for MFCv12 support. Since some part of MFCv10 specific code
holds good for MFCv12 also.

Cc: linux-...@tesla.com
Signed-off-by: Smitha T Murthy 
Signed-off-by: Aakarsh Jain 
Reviewed-by: Alim Akhtar 
Signed-off-by: Hans Verkuil 

 .../platform/samsung/s5p-mfc/s5p_mfc_common.h  | 10 
 .../media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c  |  2 +-
 .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c  | 28 +++---
 3 files changed, 20 insertions(+), 20 deletions(-)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
index 5304f42c8c72..2ae2f23c4741 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -771,11 +771,11 @@ void s5p_mfc_cleanup_queue(struct list_head *lh, struct 
vb2_queue *vq);
 #define HAS_PORTNUM(dev)   (dev ? (dev->variant ? \
(dev->variant->port_num ? 1 : 0) : 0) : 0)
 #define IS_TWOPORT(dev)(dev->variant->port_num == 2 ? 1 : 0)
-#define IS_MFCV6_PLUS(dev) (dev->variant->version >= 0x60 ? 1 : 0)
-#define IS_MFCV7_PLUS(dev) (dev->variant->version >= 0x70 ? 1 : 0)
-#define IS_MFCV8_PLUS(dev) (dev->variant->version >= 0x80 ? 1 : 0)
-#define IS_MFCV10(dev) (dev->variant->version >= 0xA0 ? 1 : 0)
-#define FW_HAS_E_MIN_SCRATCH_BUF(dev) (IS_MFCV10(dev))
+#define IS_MFCV6_PLUS(dev) ((dev)->variant->version >= 0x60)
+#define IS_MFCV7_PLUS(dev) ((dev)->variant->version >= 0x70)
+#define IS_MFCV8_PLUS(dev) ((dev)->variant->version >= 0x80)
+#define IS_MFCV10_PLUS(dev)((dev)->variant->version >= 0xA0)
+#define FW_HAS_E_MIN_SCRATCH_BUF(dev) (IS_MFCV10_PLUS(dev))
 
 #define MFC_V5_BIT BIT(0)
 #define MFC_V6_BIT BIT(1)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
index 6d3c92045c05..54b54b2fa9b1 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
@@ -236,7 +236,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
else
mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
 
-   if (IS_MFCV10(dev))
+   if (IS_MFCV10_PLUS(dev))
mfc_write(dev, 0x0, S5P_FIMV_MFC_CLOCK_OFF_V10);
 
mfc_debug(2, "Will now wait for completion of firmware transfer\n");
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
index c0df5ac9fcff..882166e4ac50 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
@@ -72,9 +72,9 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx 
*ctx)
  ctx->luma_size, ctx->chroma_size, ctx->mv_size);
mfc_debug(2, "Totals bufs: %d\n", ctx->total_dpb_count);
} else if (ctx->type == MFCINST_ENCODER) {
-   if (IS_MFCV10(dev)) {
+   if (IS_MFCV10_PLUS(dev))
ctx->tmv_buffer_size = 0;
-   } else if (IS_MFCV8_PLUS(dev))
+   else if (IS_MFCV8_PLUS(dev))
ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V8(mb_width, mb_height),
S5P_FIMV_TMV_BUFFER_ALIGN_V6);
@@ -82,7 +82,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx 
*ctx)
ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V6(mb_width, mb_height),
S5P_FIMV_TMV_BUFFER_ALIGN_V6);
-   if (IS_MFCV10(dev)) {
+   if (IS_MFCV10_PLUS(dev)) {
lcu_width = S5P_MFC_LCU_WIDTH(ctx->img_width);
lcu_height = S5P_MFC_LCU_HEIGHT(ctx->img_height);
if (ctx->codec_mode != S5P_FIMV_CODEC_HEVC_ENC) {
@@ -133,7 +133,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct 
s5p_mfc_ctx *ctx)
switch (ctx->codec_mode) {
case S5P_MFC_CODEC_H264_DEC:
case S5P_MFC_CODEC_H264_MVC_DEC:
-   if (IS_MFCV10(dev))
+   if (IS_MFCV10_PLUS(dev))
mfc_debug(2, "Use min scratch buffer size\n");
else if (IS_MFCV8_PLUS(dev))
ctx->scratch_buf_size =
@@ -152,7 +152,7 @@ static int s5p_mfc_alloc_co

[git:media_stage/master] media: s5p-mfc: Add support for UHD encoding.

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s5p-mfc: Add support for UHD encoding.
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:41:01 2023 +0530

MFC driver had restriction on max resolution of 1080p, updated it for
UHD. Added corresponding support to set recommended profile and level
for H264 in UHD scenario.

Cc: linux-...@tesla.com
Signed-off-by: Smitha T Murthy 
Signed-off-by: Aakarsh Jain 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c|  9 ++---
 drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 12 
 2 files changed, 18 insertions(+), 3 deletions(-)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
index 2f11a1e861e1..67fe0302464f 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -1461,9 +1461,12 @@ static int vidioc_try_fmt(struct file *file, void *priv, 
struct v4l2_format *f)
mfc_err("Unsupported format by this MFC version.\n");
return -EINVAL;
}
-
-   v4l_bound_align_image(_fmt_mp->width, 8, 1920, 1,
-   _fmt_mp->height, 4, 1080, 1, 0);
+   if (IS_MFCV12(dev))
+   v4l_bound_align_image(_fmt_mp->width, 8, 3840, 1, 
_fmt_mp
+   ->height, 4, 2160, 1, 0);
+   else
+   v4l_bound_align_image(_fmt_mp->width, 8, 1920, 1, 
_fmt_mp
+   ->height, 4, 1080, 1, 0);
} else {
mfc_err("invalid buf type\n");
return -EINVAL;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
index 4a0d0e228e78..572293f3b190 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
@@ -1071,6 +1071,18 @@ static int s5p_mfc_set_enc_params_h264(struct 
s5p_mfc_ctx *ctx)
reg |= ((p->num_b_frame & 0x3) << 16);
writel(reg, mfc_regs->e_gop_config);
 
+   /* UHD encoding case */
+   if (ctx->img_width == 3840 && ctx->img_height == 2160) {
+   if (p_h264->level < 51) {
+   mfc_debug(2, "Set Level 5.1 for UHD\n");
+   p_h264->level = 51;
+   }
+   if (p_h264->profile != 0x2) {
+   mfc_debug(2, "Set High profile for UHD\n");
+   p_h264->profile = 0x2;
+   }
+   }
+
/* profile & level */
reg = 0;
/** level */

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: s5p-mfc: Add support for rate controls in MFCv12

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: s5p-mfc: Add support for rate controls in MFCv12
Author:  Aakarsh Jain 
Date:Wed Dec 13 13:41:00 2023 +0530

In MFCv12, the rc configs are changed with support for CBR loose,
CBR tight and Variable Bitrate (VBR) added.

Cc: linux-...@tesla.com
Signed-off-by: Smitha T Murthy 
Signed-off-by: Aakarsh Jain 
Signed-off-by: Hans Verkuil 

 .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c  | 22 ++
 .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h  |  1 +
 2 files changed, 19 insertions(+), 4 deletions(-)

---

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
index 36aebca11313..4a0d0e228e78 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
@@ -992,10 +992,24 @@ static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx)
 
/* reaction coefficient */
if (p->rc_frame) {
-   if (p->rc_reaction_coeff < TIGHT_CBR_MAX) /* tight CBR */
-   writel(1, mfc_regs->e_rc_mode);
-   else  /* loose CBR */
-   writel(2, mfc_regs->e_rc_mode);
+   if (IS_MFCV12(dev)) {
+   /* loose CBR */
+   if (p->rc_reaction_coeff < LOOSE_CBR_MAX)
+   writel(1, mfc_regs->e_rc_mode);
+   /* tight CBR */
+   else if (p->rc_reaction_coeff < TIGHT_CBR_MAX)
+   writel(0, mfc_regs->e_rc_mode);
+   /* VBR */
+   else
+   writel(2, mfc_regs->e_rc_mode);
+   } else {
+   /* tight CBR */
+   if (p->rc_reaction_coeff < TIGHT_CBR_MAX)
+   writel(1, mfc_regs->e_rc_mode);
+   /* loose CBR */
+   else
+   writel(2, mfc_regs->e_rc_mode);
+   }
}
 
/* seq header ctrl */
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h 
b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h
index ff582eea4217..94ecb0e6e7c7 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h
@@ -40,6 +40,7 @@
 #define ENC_H264_LEVEL_MAX 42
 #define ENC_MPEG4_VOP_TIME_RES_MAX ((1 << 16) - 1)
 #define FRAME_DELTA_H264_H263  1
+#define LOOSE_CBR_MAX  5
 #define TIGHT_CBR_MAX  10
 #define ENC_HEVC_RC_FRAME_RATE_MAX ((1 << 16) - 1)
 #define ENC_HEVC_QP_INDEX_MIN  -12

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: atmel-isi: Fix crash due to missing subdev in state

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: atmel-isi: Fix crash due to missing subdev in state
Author:  Laurent Pinchart 
Date:Fri Dec 8 14:06:37 2023 +0200

As a result of converting to the stream-aware state functions, commit
bc0e8d91feec ("media: v4l: subdev: Switch to stream-aware state
functions") caused the sd pointer of the state passed to the
v4l2_subdev_state_get_crop() function to be dereferenced. It however
missed that the atmel-isi driver creates the v4l2_subdev_state instance
on the stack (which it shouldn't do, but that's a separate problem),
without initializing the sd field. This results in a null pointer
dereference.

Fix it by initializing the sd field.

Fixes: bc0e8d91feec ("media: v4l: subdev: Switch to stream-aware state 
functions")
Signed-off-by: Laurent Pinchart 
Signed-off-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/platform/atmel/atmel-isi.c | 1 +
 1 file changed, 1 insertion(+)

---

diff --git a/drivers/media/platform/atmel/atmel-isi.c 
b/drivers/media/platform/atmel/atmel-isi.c
index da58f33b6b0a..ed70c030858d 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -589,6 +589,7 @@ static int isi_try_fmt(struct atmel_isi *isi, struct 
v4l2_format *f,
struct v4l2_pix_format *pixfmt = >fmt.pix;
struct v4l2_subdev_pad_config pad_cfg = {};
struct v4l2_subdev_state pad_state = {
+   .sd = isi->entity.subdev,
.pads = _cfg,
};
struct v4l2_subdev_format format = {

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


[git:media_stage/master] media: i2c: imx290: Properly encode registers as little-endian

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: i2c: imx290: Properly encode registers as little-endian
Author:  Alexander Stein 
Date:Thu Nov 2 10:50:48 2023 +0100

The conversion to CCI also converted the multi-byte register access to
big-endian. Correct the register definition by using the correct
little-endian ones.

Fixes: af73323b9770 ("media: imx290: Convert to new CCI register access 
helpers")
Cc: sta...@vger.kernel.org
Signed-off-by: Alexander Stein 
Reviewed-by: Hans de Goede 
Reviewed-by: Laurent Pinchart 
[Sakari Ailus: Fixed the Fixes: tag.]
Signed-off-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/imx290.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

---

diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index 52ba6188911b..9967f3477433 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -41,18 +41,18 @@
 #define IMX290_WINMODE_720P(1 << 4)
 #define IMX290_WINMODE_CROP(4 << 4)
 #define IMX290_FR_FDG_SEL  CCI_REG8(0x3009)
-#define IMX290_BLKLEVEL
CCI_REG16(0x300a)
+#define IMX290_BLKLEVEL
CCI_REG16_LE(0x300a)
 #define IMX290_GAINCCI_REG8(0x3014)
-#define IMX290_VMAXCCI_REG24(0x3018)
+#define IMX290_VMAXCCI_REG24_LE(0x3018)
 #define IMX290_VMAX_MAX0x3
-#define IMX290_HMAXCCI_REG16(0x301c)
+#define IMX290_HMAXCCI_REG16_LE(0x301c)
 #define IMX290_HMAX_MAX0x
-#define IMX290_SHS1CCI_REG24(0x3020)
+#define IMX290_SHS1CCI_REG24_LE(0x3020)
 #define IMX290_WINWV_OBCCI_REG8(0x303a)
-#define IMX290_WINPV   CCI_REG16(0x303c)
-#define IMX290_WINWV   CCI_REG16(0x303e)
-#define IMX290_WINPH   CCI_REG16(0x3040)
-#define IMX290_WINWH   CCI_REG16(0x3042)
+#define IMX290_WINPV   CCI_REG16_LE(0x303c)
+#define IMX290_WINWV   CCI_REG16_LE(0x303e)
+#define IMX290_WINPH   CCI_REG16_LE(0x3040)
+#define IMX290_WINWH   CCI_REG16_LE(0x3042)
 #define IMX290_OUT_CTRLCCI_REG8(0x3046)
 #define IMX290_ODBIT_10BIT (0 << 0)
 #define IMX290_ODBIT_12BIT (1 << 0)
@@ -78,28 +78,28 @@
 #define IMX290_ADBIT2  CCI_REG8(0x317c)
 #define IMX290_ADBIT2_10BIT0x12
 #define IMX290_ADBIT2_12BIT0x00
-#define IMX290_CHIP_ID CCI_REG16(0x319a)
+#define IMX290_CHIP_ID CCI_REG16_LE(0x319a)
 #define IMX290_ADBIT3  CCI_REG8(0x31ec)
 #define IMX290_ADBIT3_10BIT0x37
 #define IMX290_ADBIT3_12BIT0x0e
 #define IMX290_REPETITION  CCI_REG8(0x3405)
 #define IMX290_PHY_LANE_NUMCCI_REG8(0x3407)
 #define IMX290_OPB_SIZE_V  CCI_REG8(0x3414)
-#define IMX290_Y_OUT_SIZE  CCI_REG16(0x3418)
-#define IMX290_CSI_DT_FMT  CCI_REG16(0x3441)
+#define IMX290_Y_OUT_SIZE  CCI_REG16_LE(0x3418)
+#define IMX290_CSI_DT_FMT  CCI_REG16_LE(0x3441)
 #define IMX290_CSI_DT_FMT_RAW100x0a0a
 #define IMX290_CSI_DT_FMT_RAW120x0c0c
 #define IMX290_CSI_LANE_MODE   CCI_REG8(0x3443)
-#define IMX290_EXTCK_FREQ  CCI_REG16(0x3444)
-#define IMX290_TCLKPOST
CCI_REG16(0x3446)
-#define IMX290_THSZERO CCI_REG16(0x3448)
-#define IMX290_THSPREPARE  CCI_REG16(0x344a)
-#define IMX290_TCLKTRAIL   CCI_REG16(0x344c)
-#define IMX290_THSTRAIL
CCI_REG16(0x344e)
-#define IMX290_TCLKZERO
CCI_REG16(0x3450)
-#define IMX290_TCLKPREPARE CCI_REG16(0x3452)
-#define IMX290_TLPXCCI_REG16(

[git:media_stage/master] media: i2c: Add support for alvium camera

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: i2c: Add support for alvium camera
Author:  Tommaso Merciai 
Date:Mon Dec 4 10:47:16 2023 +0100

The Alvium camera is shipped with sensor + isp in the same housing.
The camera can be equipped with one out of various sensor and abstract
the user from this. Camera is connected via MIPI CSI-2.

Most of the camera module features are supported, with the main exception
being fw update.

The driver provides all mandatory, optional and recommended V4L2 controls
for maximum compatibility with libcamera

References:
 - https://www.alliedvision.com/en/products/embedded-vision-solutions

Signed-off-by: Tommaso Merciai 
[Sakari Ailus: Assign ret before using it in probe and squash Tommaso's
   other fixes.]
Signed-off-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 
[hverkuil: alvium-csi2.h: SPDX must use /* */ instead of //]

 MAINTAINERS |9 +
 drivers/media/i2c/Kconfig   |   10 +
 drivers/media/i2c/Makefile  |1 +
 drivers/media/i2c/alvium-csi2.c | 2547 +++
 drivers/media/i2c/alvium-csi2.h |  475 
 5 files changed, 3042 insertions(+)

---

diff --git a/MAINTAINERS b/MAINTAINERS
index 77aabb076bd7..ea877c00c408 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -711,6 +711,15 @@ S: Maintained
 F: Documentation/devicetree/bindings/media/allegro,al5e.yaml
 F: drivers/media/platform/allegro-dvt/
 
+ALLIED VISION ALVIUM CAMERA DRIVER
+M: Tommaso Merciai 
+M: Martin Hecht 
+L: linux-me...@vger.kernel.org
+S: Maintained
+F: 
Documentation/devicetree/bindings/media/i2c/alliedvision,alvium-csi2.yaml
+F: drivers/media/i2c/alvium-csi2.c
+F: drivers/media/i2c/alvium-csi2.h
+
 ALLWINNER A10 CSI DRIVER
 M: Maxime Ripard 
 L: linux-me...@vger.kernel.org
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 525fd1ba2f48..7b4de8f44426 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -41,6 +41,16 @@ config VIDEO_APTINA_PLL
 config VIDEO_CCS_PLL
tristate
 
+config VIDEO_ALVIUM_CSI2
+   tristate "Allied Vision ALVIUM MIPI CSI-2 camera support"
+   select V4L2_CCI_I2C
+   help
+ This is a Video4Linux2 sensor-level driver for the Allied Vision
+ ALVIUM camera connected via MIPI CSI-2 interface.
+
+ To compile this driver as a module, choose M here: the
+ module will be called alvium-csi2.
+
 config VIDEO_AR0521
tristate "ON Semiconductor AR0521 sensor support"
help
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index f19b2533bc14..5169308d50b5 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_VIDEO_ADV7604) += adv7604.o
 obj-$(CONFIG_VIDEO_ADV7842) += adv7842.o
 obj-$(CONFIG_VIDEO_AK7375) += ak7375.o
 obj-$(CONFIG_VIDEO_AK881X) += ak881x.o
+obj-$(CONFIG_VIDEO_ALVIUM_CSI2) += alvium-csi2.o
 obj-$(CONFIG_VIDEO_APTINA_PLL) += aptina-pll.o
 obj-$(CONFIG_VIDEO_AR0521) += ar0521.o
 obj-$(CONFIG_VIDEO_BT819) += bt819.o
diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c
new file mode 100644
index ..c8827603eb23
--- /dev/null
+++ b/drivers/media/i2c/alvium-csi2.c
@@ -0,0 +1,2547 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Allied Vision Technologies GmbH Alvium camera driver
+ *
+ * Copyright (C) 2023 Tommaso Merciai
+ * Copyright (C) 2023 Martin Hecht
+ * Copyright (C) 2023 Avnet EMG GmbH
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "alvium-csi2.h"
+
+static const struct v4l2_mbus_framefmt alvium_csi2_default_fmt = {
+   .code = MEDIA_BUS_FMT_UYVY8_1X16,
+   .width = 640,
+   .height = 480,
+   .colorspace = V4L2_COLORSPACE_SRGB,
+   .ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(V4L2_COLORSPACE_SRGB),
+   .quantization = V4L2_QUANTIZATION_FULL_RANGE,
+   .xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(V4L2_COLORSPACE_SRGB),
+   .field = V4L2_FIELD_NONE,
+};
+
+static const struct alvium_pixfmt alvium_csi2_fmts[] = {
+   {
+   /* UYVY8_2X8 */
+   .id = ALVIUM_FMT_UYVY8_2X8,
+   .code = MEDIA_BUS_FMT_UYVY8_2X8,
+   .colorspace = V4L2_COLORSPACE_SRGB,
+   .fmt_av_bit = ALVIUM_BIT_YUV422_8,
+   .bay_av_bit = ALVIUM_BIT_BAY_NONE,
+   .mipi_fmt_regval = MIPI_CSI2_DT_YUV422_8B,
+   .bay_fmt_regval = -1,
+   .is_raw = 0,
+   }, {
+   /* UYVY8_1X16 */
+   .id = ALVIUM_FMT_UYVY8_1X16,
+   .code = MEDIA_BUS_FMT_UYVY8_1X16,
+   .colorspace = V4L2_COLORSPACE_SRGB,
+   .fmt_av_bit = ALVIUM_BIT_YUV422_8,
+   .bay_av_bit = ALVIUM_BIT_BAY_NONE,
+ 

[git:media_stage/master] media: ov2740: Add support for external clock

2023-12-13 Thread Hans Verkuil
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: ov2740: Add support for external clock
Author:  Hans de Goede 
Date:Mon Dec 4 13:39:39 2023 +0100

On some ACPI platforms, such as Chromebooks the ACPI methods to
change the power-state (_PS0 and _PS3) fully take care of powering
on/off the sensor.

On other ACPI platforms, such as e.g. various ThinkPad models with
IPU6 + ov2740 sensor, the sensor driver must control the reset GPIO
and the sensor's clock itself.

Add support for having the driver control an optional clock.

Reviewed-by: Bingbu Cao 
Signed-off-by: Hans de Goede 
Signed-off-by: Sakari Ailus 
Signed-off-by: Hans Verkuil 

 drivers/media/i2c/ov2740.c | 13 +
 1 file changed, 13 insertions(+)

---

diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index fef1b6f3f316..653cd96bb156 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -3,6 +3,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -336,6 +337,7 @@ struct ov2740 {
 
/* GPIOs, clocks */
struct gpio_desc *reset_gpio;
+   struct clk *clk;
 
/* Current mode */
const struct ov2740_mode *cur_mode;
@@ -1071,6 +1073,7 @@ static int ov2740_suspend(struct device *dev)
struct ov2740 *ov2740 = to_ov2740(sd);
 
gpiod_set_value_cansleep(ov2740->reset_gpio, 1);
+   clk_disable_unprepare(ov2740->clk);
return 0;
 }
 
@@ -1078,6 +1081,11 @@ static int ov2740_resume(struct device *dev)
 {
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct ov2740 *ov2740 = to_ov2740(sd);
+   int ret;
+
+   ret = clk_prepare_enable(ov2740->clk);
+   if (ret)
+   return ret;
 
gpiod_set_value_cansleep(ov2740->reset_gpio, 0);
msleep(20);
@@ -1105,6 +1113,11 @@ static int ov2740_probe(struct i2c_client *client)
return dev_err_probe(dev, PTR_ERR(ov2740->reset_gpio),
 "failed to get reset GPIO\n");
 
+   ov2740->clk = devm_clk_get_optional(dev, "clk");
+   if (IS_ERR(ov2740->clk))
+   return dev_err_probe(dev, PTR_ERR(ov2740->clk),
+"failed to get clock\n");
+
v4l2_i2c_subdev_init(>sd, client, _subdev_ops);
ov2740->sd.internal_ops = _internal_ops;
full_power = acpi_dev_state_d0(>dev);

___
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


<    1   2   3   4   5   6   7   8   9   10   >