[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] 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 = <&as3645a_flash &as3645a_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 = <&csi2a_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, 0x75},
+   {0x5acd, 0x75

[git:media_tree/master] media: ov08x40: Modify the tline calculation in different modes

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

Subject: media: ov08x40: Modify the tline calculation in different modes
Author:  Jason Chen 
Date:Wed Oct 18 07:58:41 2023 +0200

ov08x40 quad bayer sensor ISP has the following work modes:
- normal mode: full size
- 2x2 binned mode: binning size

In normal and binned modes, different tline calculations are
applied.

- normal mode: Tline value needs to be doubled as per the
vendor's update.

Tline time = 2 * HTS / SCLK
Exposure unit : 1 * HTS = 0.5 Tline

- 2x2 binned mode:

Tline time = 1 * HTS / SCLK
Exposure unit : 1 * HTS = 1 Tline

Signed-off-by: Jason Chen 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/i2c/ov08x40.c | 66 ++---
 1 file changed, 51 insertions(+), 15 deletions(-)

---

diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index 1f9a63cdf996..010a6017e1ad 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -34,7 +34,7 @@
 
 /* V_TIMING internal */
 #define OV08X40_REG_VTS0x380e
-#define OV08X40_VTS_30FPS  0x1388
+#define OV08X40_VTS_30FPS  0x09c4  /* the VTS need to be half in 
normal mode */
 #define OV08X40_VTS_BIN_30FPS  0x115c
 #define OV08X40_VTS_MAX0x7fff
 
@@ -44,8 +44,9 @@
 
 /* Exposure control */
 #define OV08X40_REG_EXPOSURE   0x3500
-#define OV08X40_EXPOSURE_MAX_MARGIN 31
-#define OV08X40_EXPOSURE_MIN   1
+#define OV08X40_EXPOSURE_MAX_MARGIN8
+#define OV08X40_EXPOSURE_BIN_MAX_MARGIN2
+#define OV08X40_EXPOSURE_MIN   4
 #define OV08X40_EXPOSURE_STEP  1
 #define OV08X40_EXPOSURE_DEFAULT   0x40
 
@@ -126,13 +127,17 @@ struct ov08x40_mode {
u32 vts_def;
u32 vts_min;
 
-   /* HTS */
-   u32 hts;
+   /* Line Length Pixels */
+   u32 llp;
 
/* Index of Link frequency config to be used */
u32 link_freq_index;
/* Default register values */
struct ov08x40_reg_list reg_list;
+
+   /* Exposure calculation */
+   u16 exposure_margin;
+   u16 exposure_shift;
 };
 
 static const struct ov08x40_reg mipi_data_rate_800mbps[] = {
@@ -2354,7 +2359,7 @@ static const char * const ov08x40_test_pattern_menu[] = {
 
 /* Configurations for supported link frequencies */
 #define OV08X40_LINK_FREQ_400MHZ   4ULL
-
+#define OV08X40_SCLK_96MHZ 9600ULL
 #define OV08X40_EXT_CLK1920
 #define OV08X40_DATA_LANES 4
 
@@ -2392,26 +2397,30 @@ static const struct ov08x40_mode supported_modes[] = {
.height = 2416,
.vts_def = OV08X40_VTS_30FPS,
.vts_min = OV08X40_VTS_30FPS,
-   .hts = 640,
+   .llp = 0x10aa, /* in normal mode, tline time = 2 * HTS / SCLK */
.lanes = 4,
.reg_list = {
.num_of_regs = ARRAY_SIZE(mode_3856x2416_regs),
.regs = mode_3856x2416_regs,
},
.link_freq_index = OV08X40_LINK_FREQ_400MHZ_INDEX,
+   .exposure_shift = 1,
+   .exposure_margin = OV08X40_EXPOSURE_MAX_MARGIN,
},
{
.width = 1928,
.height = 1208,
.vts_def = OV08X40_VTS_BIN_30FPS,
.vts_min = OV08X40_VTS_BIN_30FPS,
-   .hts = 720,
+   .llp = 0x960,
.lanes = 4,
.reg_list = {
.num_of_regs = ARRAY_SIZE(mode_1928x1208_regs),
.regs = mode_1928x1208_regs,
},
.link_freq_index = OV08X40_LINK_FREQ_400MHZ_INDEX,
+   .exposure_shift = 0,
+   .exposure_margin = OV08X40_EXPOSURE_BIN_MAX_MARGIN,
},
 };
 
@@ -2667,13 +2676,23 @@ static int ov08x40_set_ctrl(struct v4l2_ctrl *ctrl)
 struct ov08x40, ctrl_handler);
struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd);
s64 max;
+   int exp;
+   int fll;
int ret = 0;
 
/* Propagate change of current control to all related controls */
switch (ctrl->id) {
case V4L2_CID_VBLANK:
/* Update max exposure while meeting expected vblanking */
-   max = ov08x->cur_mode->height + ctrl->val - 
OV08X40_EXPOSURE_MAX_MARGIN;
+   /*
+* because in normal mode, 1 HTS = 0.5 tline
+* fps = sclk / hts / vts
+* so the vts value needs to be double
+*/
+   max = ((ov08x->cur_mode->height + ctrl->val) <<
+   ov08x->cur_mode->exposure_shift) -
+   ov08x->cur_mode->exposure_margin;
+
__v4l2_ctrl_modify_range(ov08x->exposure,

[git:media_tree/master] media: ov08x40: Avoid sensor probing in D0 state

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

Subject: media: ov08x40: Avoid sensor probing in D0 state
Author:  Jason Chen 
Date:Mon Jan 22 03:54:34 2024 +0100

When the system enters the D0 state and attempt to probe the device,
another component, such as LED, will also be pulled high due to the
hardware design. It's advisable to keep the device being probed in
a different D state.

Signed-off-by: Jason Chen 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/i2c/ov08x40.c | 32 +---
 1 file changed, 21 insertions(+), 11 deletions(-)

---

diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index abbb0b774d43..1f9a63cdf996 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -2432,6 +2432,9 @@ struct ov08x40 {
 
/* Mutex for serialized access */
struct mutex mutex;
+
+   /* True if the device has been identified */
+   bool identified;
 };
 
 #define to_ov08x40(_sd)container_of(_sd, struct ov08x40, sd)
@@ -2948,6 +2951,9 @@ static int ov08x40_identify_module(struct ov08x40 *ov08x)
int ret;
u32 val;
 
+   if (ov08x->identified)
+   return 0;
+
ret = ov08x40_read_reg(ov08x, OV08X40_REG_CHIP_ID,
   OV08X40_REG_VALUE_24BIT, &val);
if (ret)
@@ -2956,9 +2962,11 @@ static int ov08x40_identify_module(struct ov08x40 *ov08x)
if (val != OV08X40_CHIP_ID) {
dev_err(&client->dev, "chip id mismatch: %x!=%x\n",
OV08X40_CHIP_ID, val);
-   return -EIO;
+   return -ENXIO;
}
 
+   ov08x->identified = true;
+
return 0;
 }
 
@@ -3175,6 +3183,7 @@ static int ov08x40_probe(struct i2c_client *client)
 {
struct ov08x40 *ov08x;
int ret;
+   bool full_power;
 
/* Check HW config */
ret = ov08x40_check_hwcfg(&client->dev);
@@ -3190,11 +3199,14 @@ static int ov08x40_probe(struct i2c_client *client)
/* Initialize subdev */
v4l2_i2c_subdev_init(&ov08x->sd, client, &ov08x40_subdev_ops);
 
-   /* Check module identity */
-   ret = ov08x40_identify_module(ov08x);
-   if (ret) {
-   dev_err(&client->dev, "failed to find sensor: %d\n", ret);
-   return ret;
+   full_power = acpi_dev_state_d0(&client->dev);
+   if (full_power) {
+   /* Check module identity */
+   ret = ov08x40_identify_module(ov08x);
+   if (ret) {
+   dev_err(&client->dev, "failed to find sensor: %d\n", 
ret);
+   return ret;
+   }
}
 
/* Set default mode to max resolution */
@@ -3222,11 +3234,8 @@ static int ov08x40_probe(struct i2c_client *client)
if (ret < 0)
goto error_media_entity;
 
-   /*
-* Device is already turned on by i2c-core with ACPI domain PM.
-* Enable runtime PM and turn off the device.
-*/
-   pm_runtime_set_active(&client->dev);
+   if (full_power)
+   pm_runtime_set_active(&client->dev);
pm_runtime_enable(&client->dev);
pm_runtime_idle(&client->dev);
 
@@ -3270,6 +3279,7 @@ static struct i2c_driver ov08x40_i2c_driver = {
},
.probe = ov08x40_probe,
.remove = ov08x40_remove,
+   .flags = I2C_DRV_ACPI_WAIVE_D0_PROBE,
 };
 
 module_i2c_driver(ov08x40_i2c_driver);


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

2024-02-06 Thread Mauro Carvalho Chehab
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: Mauro Carvalho Chehab 

 .../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, 59 insertions(+), 1154 deletions(-)

---

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.yaml 
b/Documentation/devicetree/bindings/media/video-interfaces.yaml
index 26e3e7d7c67b..ea511f2fed98 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/uint64-array
+$ref: /schemas/types.yaml#/definitions/uint32-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 a3cf3f443785..728a8fcf25b3 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 = <&as3645a_flash &as3645a_indicator>;
port {
smia_1_1: endpoint {
-   link-frequencies = /bits/ 64 <19920 
21000 49920>;
+   link-frequencies = /bits/ 32 <19920 
21000 49920>;
clock-lanes = <0>;
data-lanes = <1 2>;
remote-endpoint = <&csi2a_ep>;
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},
-   

[git:media_tree/master] media: imx355: Use v4l2_link_freq_to_bitmap helper

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

Subject: media: imx355: Use v4l2_link_freq_to_bitmap helper
Author:  Sakari Ailus 
Date:Mon Jan 8 16:18:05 2024 +0100

Use the v4l2_link_freq_to_bitmap() helper to figure out which
driver-supported link freq can be used on a given system.

Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/i2c/imx355.c | 53 --
 1 file changed, 14 insertions(+), 39 deletions(-)

---

diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c
index 8c995c58743a..7e9c2f65fa08 100644
--- a/drivers/media/i2c/imx355.c
+++ b/drivers/media/i2c/imx355.c
@@ -56,7 +56,7 @@
 #define IMX355_REG_ORIENTATION 0x0101
 
 /* default link frequency and external clock */
-#define IMX355_LINK_FREQ_DEFAULT   36000
+#define IMX355_LINK_FREQ_DEFAULT   36000LL
 #define IMX355_EXT_CLK 1920
 #define IMX355_LINK_FREQ_INDEX 0
 
@@ -93,8 +93,7 @@ struct imx355_mode {
 
 struct imx355_hwcfg {
u32 ext_clk;/* sensor external clk */
-   s64 *link_freqs;/* CSI-2 link frequencies */
-   unsigned int nr_of_link_freqs;
+   unsigned long link_freq_bitmap;
 };
 
 struct imx355 {
@@ -115,7 +114,6 @@ struct imx355 {
const struct imx355_mode *cur_mode;
 
struct imx355_hwcfg *hwcfg;
-   s64 link_def_freq;  /* CSI-2 link default frequency */
 
/*
 * Mutex for serialized access:
@@ -879,7 +877,10 @@ static const char * const imx355_test_pattern_menu[] = {
"Pseudorandom Sequence (PN9)",
 };
 
-/* supported link frequencies */
+/*
+ * When adding more than the one below, make sure the disallowed ones will
+ * actually be disabled in the LINK_FREQ control.
+ */
 static const s64 link_freq_menu_items[] = {
IMX355_LINK_FREQ_DEFAULT,
 };
@@ -1356,7 +1357,7 @@ imx355_set_pad_format(struct v4l2_subdev *sd,
*framefmt = fmt->format;
} else {
imx355->cur_mode = mode;
-   pixel_rate = imx355->link_def_freq * 2 * 4;
+   pixel_rate = IMX355_LINK_FREQ_DEFAULT * 2 * 4;
do_div(pixel_rate, 10);
__v4l2_ctrl_s_ctrl_int64(imx355->pixel_rate, pixel_rate);
/* Update limits and set FPS to default */
@@ -1543,7 +1544,7 @@ static int imx355_init_controls(struct imx355 *imx355)
imx355->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
/* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
-   pixel_rate = imx355->link_def_freq * 2 * 4;
+   pixel_rate = IMX355_LINK_FREQ_DEFAULT * 2 * 4;
do_div(pixel_rate, 10);
/* By default, PIXEL_RATE is read only */
imx355->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops,
@@ -1620,7 +1621,6 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct 
device *dev)
};
struct fwnode_handle *ep;
struct fwnode_handle *fwnode = dev_fwnode(dev);
-   unsigned int i;
int ret;
 
if (!fwnode)
@@ -1652,24 +1652,14 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct 
device *dev)
goto out_err;
}
 
-   dev_dbg(dev, "num of link freqs: %d", bus_cfg.nr_of_link_frequencies);
-   if (!bus_cfg.nr_of_link_frequencies) {
-   dev_warn(dev, "no link frequencies defined");
-   goto out_err;
-   }
-
-   cfg->nr_of_link_freqs = bus_cfg.nr_of_link_frequencies;
-   cfg->link_freqs = devm_kcalloc(dev,
-  bus_cfg.nr_of_link_frequencies + 1,
-  sizeof(*cfg->link_freqs), GFP_KERNEL);
-   if (!cfg->link_freqs)
+   ret = v4l2_link_freq_to_bitmap(dev, bus_cfg.link_frequencies,
+  bus_cfg.nr_of_link_frequencies,
+  link_freq_menu_items,
+  ARRAY_SIZE(link_freq_menu_items),
+  &cfg->link_freq_bitmap);
+   if (ret)
goto out_err;
 
-   for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++) {
-   cfg->link_freqs[i] = bus_cfg.link_frequencies[i];
-   dev_dbg(dev, "link_freq[%d] = %lld", i, cfg->link_freqs[i]);
-   }
-
v4l2_fwnode_endpoint_free(&bus_cfg);
fwnode_handle_put(ep);
return cfg;
@@ -1684,7 +1674,6 @@ static int imx355_probe(struct i2c_client *client)
 {
struct imx355 *imx355;
int ret;
-   u32 i;
 
imx355 = devm_kzalloc(&client->dev, sizeof(*imx355), GFP_KERNEL);
if (!imx355)
@@ -1709,20 +1698,6 @@ static int imx355_probe(struct i2c_client *client)
goto error_probe;
}
 
-   imx355->link_def_freq = link_freq_menu_items[IMX355_LINK_FREQ_INDEX];
-   for (i = 0; i < imx355->hwcfg->nr_of_link_freqs; i++) {

[git:media_tree/master] media: imx334: Use v4l2_link_freq_to_bitmap helper

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

Subject: media: imx334: Use v4l2_link_freq_to_bitmap helper
Author:  Sakari Ailus 
Date:Mon Jan 8 16:18:03 2024 +0100

Use the v4l2_link_freq_to_bitmap() helper to figure out which
driver-supported link frequencies can be used on a given system.

Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/i2c/imx334.c | 41 -
 1 file changed, 12 insertions(+), 29 deletions(-)

---

diff --git a/drivers/media/i2c/imx334.c b/drivers/media/i2c/imx334.c
index 6725b3e2a73e..40863d87d341 100644
--- a/drivers/media/i2c/imx334.c
+++ b/drivers/media/i2c/imx334.c
@@ -136,7 +136,7 @@ struct imx334_mode {
  * @vblank: Vertical blanking in lines
  * @cur_mode: Pointer to current selected sensor mode
  * @mutex: Mutex for serializing sensor controls
- * @menu_skip_mask: Menu skip mask for link_freq_ctrl
+ * @link_freq_bitmap: Menu bitmap for link_freq_ctrl
  * @cur_code: current selected format code
  */
 struct imx334 {
@@ -158,7 +158,7 @@ struct imx334 {
u32 vblank;
const struct imx334_mode *cur_mode;
struct mutex mutex;
-   unsigned long menu_skip_mask;
+   unsigned long link_freq_bitmap;
u32 cur_code;
 };
 
@@ -954,9 +954,9 @@ static int imx334_init_state(struct v4l2_subdev *sd,
imx334_fill_pad_format(imx334, imx334->cur_mode, &fmt);
 
__v4l2_ctrl_modify_range(imx334->link_freq_ctrl, 0,
-__fls(imx334->menu_skip_mask),
-~(imx334->menu_skip_mask),
-__ffs(imx334->menu_skip_mask));
+__fls(imx334->link_freq_bitmap),
+~(imx334->link_freq_bitmap),
+__ffs(imx334->link_freq_bitmap));
 
mutex_unlock(&imx334->mutex);
 
@@ -1112,7 +1112,6 @@ static int imx334_parse_hw_config(struct imx334 *imx334)
};
struct fwnode_handle *ep;
unsigned long rate;
-   unsigned int i, j;
int ret;
 
if (!fwnode)
@@ -1157,26 +1156,10 @@ static int imx334_parse_hw_config(struct imx334 *imx334)
goto done_endpoint_free;
}
 
-   if (!bus_cfg.nr_of_link_frequencies) {
-   dev_err(imx334->dev, "no link frequencies defined");
-   ret = -EINVAL;
-   goto done_endpoint_free;
-   }
-
-   for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++) {
-   for (j = 0; j < ARRAY_SIZE(link_freq); j++) {
-   if (bus_cfg.link_frequencies[i] == link_freq[j]) {
-   set_bit(j, &imx334->menu_skip_mask);
-   break;
-   }
-   }
-
-   if (j == ARRAY_SIZE(link_freq)) {
-   ret = dev_err_probe(imx334->dev, -EINVAL,
-   "no supported link freq found\n");
-   goto done_endpoint_free;
-   }
-   }
+   ret = v4l2_link_freq_to_bitmap(imx334->dev, bus_cfg.link_frequencies,
+  bus_cfg.nr_of_link_frequencies,
+  link_freq, ARRAY_SIZE(link_freq),
+  &imx334->link_freq_bitmap);
 
 done_endpoint_free:
v4l2_fwnode_endpoint_free(&bus_cfg);
@@ -1310,8 +1293,8 @@ static int imx334_init_controls(struct imx334 *imx334)
imx334->link_freq_ctrl = v4l2_ctrl_new_int_menu(ctrl_hdlr,
&imx334_ctrl_ops,
V4L2_CID_LINK_FREQ,
-   
__fls(imx334->menu_skip_mask),
-   
__ffs(imx334->menu_skip_mask),
+   
__fls(imx334->link_freq_bitmap),
+   
__ffs(imx334->link_freq_bitmap),
link_freq);
 
if (imx334->link_freq_ctrl)
@@ -1386,7 +1369,7 @@ static int imx334_probe(struct i2c_client *client)
}
 
/* Set default mode to max resolution */
-   imx334->cur_mode = &supported_modes[__ffs(imx334->menu_skip_mask)];
+   imx334->cur_mode = &supported_modes[__ffs(imx334->link_freq_bitmap)];
imx334->cur_code = imx334_mbus_codes[0];
imx334->vblank = imx334->cur_mode->vblank;
 


[git:media_tree/master] media: imx319: Use v4l2_link_freq_to_bitmap helper

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

Subject: media: imx319: Use v4l2_link_freq_to_bitmap helper
Author:  Sakari Ailus 
Date:Mon Jan 8 16:18:04 2024 +0100

Use the v4l2_link_freq_to_bitmap() helper to figure out which
driver-supported link freq can be used on a given system.

Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/i2c/imx319.c | 53 --
 1 file changed, 14 insertions(+), 39 deletions(-)

---

diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c
index e47eff672e0c..8fe3933f3146 100644
--- a/drivers/media/i2c/imx319.c
+++ b/drivers/media/i2c/imx319.c
@@ -70,7 +70,7 @@
 #define IMX319_REG_ORIENTATION 0x0101
 
 /* default link frequency and external clock */
-#define IMX319_LINK_FREQ_DEFAULT   48240
+#define IMX319_LINK_FREQ_DEFAULT   48240LL
 #define IMX319_EXT_CLK 1920
 #define IMX319_LINK_FREQ_INDEX 0
 
@@ -107,8 +107,7 @@ struct imx319_mode {
 
 struct imx319_hwcfg {
u32 ext_clk;/* sensor external clk */
-   s64 *link_freqs;/* CSI-2 link frequencies */
-   unsigned int nr_of_link_freqs;
+   unsigned long link_freq_bitmap;
 };
 
 struct imx319 {
@@ -129,7 +128,6 @@ struct imx319 {
const struct imx319_mode *cur_mode;
 
struct imx319_hwcfg *hwcfg;
-   s64 link_def_freq;  /* CSI-2 link default frequency */
 
/*
 * Mutex for serialized access:
@@ -1654,7 +1652,10 @@ static const char * const imx319_test_pattern_menu[] = {
"Pseudorandom Sequence (PN9)",
 };
 
-/* supported link frequencies */
+/*
+ * When adding more than the one below, make sure the disallowed ones will
+ * actually be disabled in the LINK_FREQ control.
+ */
 static const s64 link_freq_menu_items[] = {
IMX319_LINK_FREQ_DEFAULT,
 };
@@ -2058,7 +2059,7 @@ imx319_set_pad_format(struct v4l2_subdev *sd,
*framefmt = fmt->format;
} else {
imx319->cur_mode = mode;
-   pixel_rate = imx319->link_def_freq * 2 * 4;
+   pixel_rate = IMX319_LINK_FREQ_DEFAULT * 2 * 4;
do_div(pixel_rate, 10);
__v4l2_ctrl_s_ctrl_int64(imx319->pixel_rate, pixel_rate);
/* Update limits and set FPS to default */
@@ -2255,7 +2256,7 @@ static int imx319_init_controls(struct imx319 *imx319)
imx319->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
/* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
-   pixel_rate = imx319->link_def_freq * 2 * 4;
+   pixel_rate = IMX319_LINK_FREQ_DEFAULT * 2 * 4;
do_div(pixel_rate, 10);
/* By default, PIXEL_RATE is read only */
imx319->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
@@ -2332,7 +2333,6 @@ static struct imx319_hwcfg *imx319_get_hwcfg(struct 
device *dev)
};
struct fwnode_handle *ep;
struct fwnode_handle *fwnode = dev_fwnode(dev);
-   unsigned int i;
int ret;
 
if (!fwnode)
@@ -2364,24 +2364,14 @@ static struct imx319_hwcfg *imx319_get_hwcfg(struct 
device *dev)
goto out_err;
}
 
-   dev_dbg(dev, "num of link freqs: %d", bus_cfg.nr_of_link_frequencies);
-   if (!bus_cfg.nr_of_link_frequencies) {
-   dev_warn(dev, "no link frequencies defined");
-   goto out_err;
-   }
-
-   cfg->nr_of_link_freqs = bus_cfg.nr_of_link_frequencies;
-   cfg->link_freqs = devm_kcalloc(dev,
-  bus_cfg.nr_of_link_frequencies + 1,
-  sizeof(*cfg->link_freqs), GFP_KERNEL);
-   if (!cfg->link_freqs)
+   ret = v4l2_link_freq_to_bitmap(dev, bus_cfg.link_frequencies,
+  bus_cfg.nr_of_link_frequencies,
+  link_freq_menu_items,
+  ARRAY_SIZE(link_freq_menu_items),
+  &cfg->link_freq_bitmap);
+   if (ret)
goto out_err;
 
-   for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++) {
-   cfg->link_freqs[i] = bus_cfg.link_frequencies[i];
-   dev_dbg(dev, "link_freq[%d] = %lld", i, cfg->link_freqs[i]);
-   }
-
v4l2_fwnode_endpoint_free(&bus_cfg);
fwnode_handle_put(ep);
return cfg;
@@ -2397,7 +2387,6 @@ static int imx319_probe(struct i2c_client *client)
struct imx319 *imx319;
bool full_power;
int ret;
-   u32 i;
 
imx319 = devm_kzalloc(&client->dev, sizeof(*imx319), GFP_KERNEL);
if (!imx319)
@@ -2425,20 +2414,6 @@ static int imx319_probe(struct i2c_client *client)
goto error_probe;
}
 
-   imx319->link_def_freq = link_freq_menu_items[IMX319_LINK_FREQ_INDEX];
-   for (i = 0; i < imx319->hwcfg-

[git:media_tree/master] media: v4l: Add a helper for setting up link-frequencies control

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

Subject: media: v4l: Add a helper for setting up link-frequencies control
Author:  Sakari Ailus 
Date:Mon Jan 8 16:18:02 2024 +0100

Add a helper for obtaining supported link frequencies in form most drivers
need them. The result is a bitmap of supported controls.

Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/v4l2-core/v4l2-common.c | 47 +++
 include/media/v4l2-common.h   | 25 +++
 2 files changed, 72 insertions(+)

---

diff --git a/drivers/media/v4l2-core/v4l2-common.c 
b/drivers/media/v4l2-core/v4l2-common.c
index 273d83de2a87..d34d210908d9 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -585,3 +585,50 @@ u32 v4l2_fraction_to_interval(u32 numerator, u32 
denominator)
return denominator ? numerator * multiplier / denominator : 0;
 }
 EXPORT_SYMBOL_GPL(v4l2_fraction_to_interval);
+
+int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
+unsigned int num_of_fw_link_freqs,
+const s64 *driver_link_freqs,
+unsigned int num_of_driver_link_freqs,
+unsigned long *bitmap)
+{
+   unsigned int i;
+
+   *bitmap = 0;
+
+   if (!num_of_fw_link_freqs) {
+   dev_err(dev, "no link frequencies in firmware\n");
+   return -ENODATA;
+   }
+
+   for (i = 0; i < num_of_fw_link_freqs; i++) {
+   unsigned int j;
+
+   for (j = 0; j < num_of_driver_link_freqs; j++) {
+   if (fw_link_freqs[i] != driver_link_freqs[j])
+   continue;
+
+   dev_dbg(dev, "enabling link frequency %lld Hz\n",
+   driver_link_freqs[j]);
+   *bitmap |= BIT(j);
+   break;
+   }
+   }
+
+   if (!*bitmap) {
+   dev_err(dev, "no matching link frequencies found\n");
+
+   dev_dbg(dev, "specified in firmware:\n");
+   for (i = 0; i < num_of_fw_link_freqs; i++)
+   dev_dbg(dev, "\t%llu Hz\n", fw_link_freqs[i]);
+
+   dev_dbg(dev, "driver supported:\n");
+   for (i = 0; i < num_of_driver_link_freqs; i++)
+   dev_dbg(dev, "\t%lld Hz\n", driver_link_freqs[i]);
+
+   return -ENOENT;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_link_freq_to_bitmap);
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index acf5be24a5ca..cd2163f24f8a 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -547,6 +547,31 @@ void v4l2_simplify_fraction(u32 *numerator, u32 
*denominator,
unsigned int n_terms, unsigned int threshold);
 u32 v4l2_fraction_to_interval(u32 numerator, u32 denominator);
 
+/**
+ * v4l2_link_freq_to_bitmap - Figure out platform-supported link frequencies
+ * @dev: The struct device
+ * @fw_link_freqs: Array of link frequencies from firmware
+ * @num_of_fw_link_freqs: Number of entries in @fw_link_freqs
+ * @driver_link_freqs: Array of link frequencies supported by the driver
+ * @num_of_driver_link_freqs: Number of entries in @driver_link_freqs
+ * @bitmap: Bitmap of driver-supported link frequencies found in @fw_link_freqs
+ *
+ * This function checks which driver-supported link frequencies are enabled in
+ * 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.
+ */
+int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
+unsigned int num_of_fw_link_freqs,
+const s64 *driver_link_freqs,
+unsigned int num_of_driver_link_freqs,
+unsigned long *bitmap);
+
 static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
 {
/*


[git:media_tree/master] media: i2c: imx415: Add more clock configurations

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

Subject: media: i2c: imx415: Add more clock configurations
Author:  Alexander Stein 
Date:Wed Jan 17 08:39:36 2024 +0100

Complete the list from "INCK Setting" section in IMX415-AAQR-C
(Rev. E19504, 2019/05/21). For consistency suffix all lane rate values by
UL, which is needed for 237600 anyway.

Signed-off-by: Alexander Stein 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/i2c/imx415.c | 265 -
 1 file changed, 260 insertions(+), 5 deletions(-)

---

diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c
index e52437fb5087..a20b0db330d3 100644
--- a/drivers/media/i2c/imx415.c
+++ b/drivers/media/i2c/imx415.c
@@ -114,7 +114,7 @@ struct imx415_clk_params {
 /* INCK Settings - includes all lane rate and INCK dependent registers */
 static const struct imx415_clk_params imx415_clk_params[] = {
{
-   .lane_rate = 59400,
+   .lane_rate = 59400UL,
.inck = 2700,
.regs[0] = { IMX415_BCWAIT_TIME, 0x05D },
.regs[1] = { IMX415_CPWAIT_TIME, 0x042 },
@@ -129,7 +129,37 @@ static const struct imx415_clk_params imx415_clk_params[] 
= {
.regs[10] = { IMX415_TXCLKESC_FREQ, 0x06C0 },
},
{
-   .lane_rate = 72000,
+   .lane_rate = 59400UL,
+   .inck = 37125000,
+   .regs[0] = { IMX415_BCWAIT_TIME, 0x07F },
+   .regs[1] = { IMX415_CPWAIT_TIME, 0x05B },
+   .regs[2] = { IMX415_SYS_MODE, 0x7 },
+   .regs[3] = { IMX415_INCKSEL1, 0x00 },
+   .regs[4] = { IMX415_INCKSEL2, 0x24 },
+   .regs[5] = { IMX415_INCKSEL3, 0x080 },
+   .regs[6] = { IMX415_INCKSEL4, 0x0E0 },
+   .regs[7] = { IMX415_INCKSEL5, 0x24 },
+   .regs[8] = { IMX415_INCKSEL6, 0x0 },
+   .regs[9] = { IMX415_INCKSEL7, 0x1 },
+   .regs[10] = { IMX415_TXCLKESC_FREQ, 0x0984 },
+   },
+   {
+   .lane_rate = 59400UL,
+   .inck = 7425,
+   .regs[0] = { IMX415_BCWAIT_TIME, 0x0FF },
+   .regs[1] = { IMX415_CPWAIT_TIME, 0x0B6 },
+   .regs[2] = { IMX415_SYS_MODE, 0x7 },
+   .regs[3] = { IMX415_INCKSEL1, 0x00 },
+   .regs[4] = { IMX415_INCKSEL2, 0x28 },
+   .regs[5] = { IMX415_INCKSEL3, 0x080 },
+   .regs[6] = { IMX415_INCKSEL4, 0x0E0 },
+   .regs[7] = { IMX415_INCKSEL5, 0x28 },
+   .regs[8] = { IMX415_INCKSEL6, 0x0 },
+   .regs[9] = { IMX415_INCKSEL7, 0x1 },
+   .regs[10] = { IMX415_TXCLKESC_FREQ, 0x1290 },
+   },
+   {
+   .lane_rate = 72000UL,
.inck = 2400,
.regs[0] = { IMX415_BCWAIT_TIME, 0x054 },
.regs[1] = { IMX415_CPWAIT_TIME, 0x03B },
@@ -144,7 +174,22 @@ static const struct imx415_clk_params imx415_clk_params[] 
= {
.regs[10] = { IMX415_TXCLKESC_FREQ, 0x0600 },
},
{
-   .lane_rate = 89100,
+   .lane_rate = 72000UL,
+   .inck = 7200,
+   .regs[0] = { IMX415_BCWAIT_TIME, 0x0F8 },
+   .regs[1] = { IMX415_CPWAIT_TIME, 0x0B0 },
+   .regs[2] = { IMX415_SYS_MODE, 0x9 },
+   .regs[3] = { IMX415_INCKSEL1, 0x00 },
+   .regs[4] = { IMX415_INCKSEL2, 0x28 },
+   .regs[5] = { IMX415_INCKSEL3, 0x0A0 },
+   .regs[6] = { IMX415_INCKSEL4, 0x0E0 },
+   .regs[7] = { IMX415_INCKSEL5, 0x28 },
+   .regs[8] = { IMX415_INCKSEL6, 0x0 },
+   .regs[9] = { IMX415_INCKSEL7, 0x1 },
+   .regs[10] = { IMX415_TXCLKESC_FREQ, 0x1200 },
+   },
+   {
+   .lane_rate = 89100UL,
.inck = 2700,
.regs[0] = { IMX415_BCWAIT_TIME, 0x05D },
.regs[1] = { IMX415_CPWAIT_TIME, 0x042 },
@@ -159,7 +204,37 @@ static const struct imx415_clk_params imx415_clk_params[] 
= {
.regs[10] = { IMX415_TXCLKESC_FREQ, 0x06C0 },
},
{
-   .lane_rate = 144000,
+   .lane_rate = 89100UL,
+   .inck = 37125000,
+   .regs[0] = { IMX415_BCWAIT_TIME, 0x07F },
+   .regs[1] = { IMX415_CPWAIT_TIME, 0x05B },
+   .regs[2] = { IMX415_SYS_MODE, 0x5 },
+   .regs[3] = { IMX415_INCKSEL1, 0x00 },
+   .regs[4] = { IMX415_INCKSEL2, 0x24 },
+   .regs[5] = { IMX415_INCKSEL3, 0x0C0 },
+   .regs[6] = { IMX415_INCKSEL4, 0x0E0 },
+   .regs[7] = { IMX415_INCKSEL5, 0x24 },
+   .regs[8] = { IMX415_INCKSEL6, 0x0 },
+   .regs[9] = { IMX415_INCKSEL7, 0x1 },
+

[git:media_tree/master] media: tc358743: register v4l2 async device only after successful setup

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

Subject: media: tc358743: register v4l2 async device only after successful setup
Author:  Alexander Stein 
Date:Wed Jan 10 10:01:11 2024 +0100

Ensure the device has been setup correctly before registering the v4l2
async device, thus allowing userspace to access.

Signed-off-by: Alexander Stein 
Reviewed-by: Robert Foss 
Fixes: 4c5211a10039 ("[media] tc358743: register v4l2 asynchronous subdevice")
Cc: sta...@vger.kernel.org
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/i2c/tc358743.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

---

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 2785935da497..558152575d10 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -2091,9 +2091,6 @@ static int tc358743_probe(struct i2c_client *client)
state->mbus_fmt_code = MEDIA_BUS_FMT_RGB888_1X24;
 
sd->dev = &client->dev;
-   err = v4l2_async_register_subdev(sd);
-   if (err < 0)
-   goto err_hdl;
 
mutex_init(&state->confctl_mutex);
 
@@ -2151,6 +2148,10 @@ static int tc358743_probe(struct i2c_client *client)
if (err)
goto err_work_queues;
 
+   err = v4l2_async_register_subdev(sd);
+   if (err < 0)
+   goto err_work_queues;
+
v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
  client->addr << 1, client->adapter->name);
 


[git:media_tree/master] media: v4l2: cci: print leading 0 on error

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

Subject: media: v4l2: cci: print leading 0 on error
Author:  Julien Massot 
Date:Thu Jan 11 14:20:03 2024 +0100

In some error cases leading '0' for register address
were missing.

Fixes: 613cbb91e9ce ("media: Add MIPI CCI register access helper functions")
Signed-off-by: Julien Massot 
Reviewed-by: Hans de Goede 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/v4l2-core/v4l2-cci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/v4l2-core/v4l2-cci.c 
b/drivers/media/v4l2-core/v4l2-cci.c
index 10005c80f43b..ee3475bed37f 100644
--- a/drivers/media/v4l2-core/v4l2-cci.c
+++ b/drivers/media/v4l2-core/v4l2-cci.c
@@ -32,7 +32,7 @@ int cci_read(struct regmap *map, u32 reg, u64 *val, int *err)
 
ret = regmap_bulk_read(map, reg, buf, len);
if (ret) {
-   dev_err(regmap_get_device(map), "Error reading reg 0x%4x: %d\n",
+   dev_err(regmap_get_device(map), "Error reading reg 0x%04x: 
%d\n",
reg, ret);
goto out;
}
@@ -131,7 +131,7 @@ int cci_write(struct regmap *map, u32 reg, u64 val, int 
*err)
 
ret = regmap_bulk_write(map, reg, buf, len);
if (ret)
-   dev_err(regmap_get_device(map), "Error writing reg 0x%4x: %d\n",
+   dev_err(regmap_get_device(map), "Error writing reg 0x%04x: 
%d\n",
reg, ret);
 
 out:


[git:media_tree/master] media: i2c: st-vgxy61: Convert to CCI register access helpers

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

Subject: media: i2c: st-vgxy61: Convert to CCI register access helpers
Author:  Julien Massot 
Date:Fri Jan 12 10:52:28 2024 +0100

Use the new common CCI register access helpers to replace the private
register access helpers in the st-vgxy61 driver. This simplifies the
driver by reducing the amount of code.

st-vgxy61 devices use little endianness arrangement, therefore
the driver uses the CCI_REGx_LE registers definition.

Signed-off-by: Julien Massot 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/i2c/Kconfig |   1 +
 drivers/media/i2c/st-vgxy61.c | 390 +-
 2 files changed, 154 insertions(+), 237 deletions(-)

---

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 4c3435921f19..9d9b52d93131 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -658,6 +658,7 @@ config VIDEO_S5K6A3
 
 config VIDEO_ST_VGXY61
tristate "ST VGXY61 sensor support"
+   select V4L2_CCI_I2C
depends on OF && GPIOLIB
help
  This is a Video4Linux2 sensor driver for the ST VGXY61
diff --git a/drivers/media/i2c/st-vgxy61.c b/drivers/media/i2c/st-vgxy61.c
index e4d37a197724..2d64466d7ecf 100644
--- a/drivers/media/i2c/st-vgxy61.c
+++ b/drivers/media/i2c/st-vgxy61.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -19,79 +20,74 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
-#define VGXY61_REG_8BIT(n) ((1 << 16) | (n))
-#define VGXY61_REG_16BIT(n)((2 << 16) | (n))
-#define VGXY61_REG_32BIT(n)((4 << 16) | (n))
-#define VGXY61_REG_SIZE_SHIFT  16
-#define VGXY61_REG_ADDR_MASK   0x
-
-#define VGXY61_REG_MODEL_IDVGXY61_REG_16BIT(0x)
+#define VGXY61_REG_MODEL_IDCCI_REG16_LE(0x)
 #define VG5661_MODEL_ID0x5661
 #define VG5761_MODEL_ID0x5761
-#define VGXY61_REG_REVISIONVGXY61_REG_16BIT(0x0002)
-#define VGXY61_REG_FWPATCH_REVISIONVGXY61_REG_16BIT(0x0014)
-#define VGXY61_REG_FWPATCH_START_ADDR  VGXY61_REG_8BIT(0x2000)
-#define VGXY61_REG_SYSTEM_FSM  VGXY61_REG_8BIT(0x0020)
+#define VGXY61_REG_REVISIONCCI_REG16_LE(0x0002)
+#define VGXY61_REG_FWPATCH_REVISIONCCI_REG16_LE(0x0014)
+#define VGXY61_REG_FWPATCH_START_ADDR  CCI_REG8(0x2000)
+#define VGXY61_REG_SYSTEM_FSM  CCI_REG8(0x0020)
 #define VGXY61_SYSTEM_FSM_SW_STBY  0x03
 #define VGXY61_SYSTEM_FSM_STREAMING0x04
-#define VGXY61_REG_NVM VGXY61_REG_8BIT(0x0023)
+#define VGXY61_REG_NVM CCI_REG8(0x0023)
 #define VGXY61_NVM_OK  0x04
-#define VGXY61_REG_STBY
VGXY61_REG_8BIT(0x0201)
+#define VGXY61_REG_STBYCCI_REG8(0x0201)
 #define VGXY61_STBY_NO_REQ 0
 #define VGXY61_STBY_REQ_TMP_READ   BIT(2)
-#define VGXY61_REG_STREAMING   VGXY61_REG_8BIT(0x0202)
+#define VGXY61_REG_STREAMING   CCI_REG8(0x0202)
 #define VGXY61_STREAMING_NO_REQ0
 #define VGXY61_STREAMING_REQ_STOP  BIT(0)
 #define VGXY61_STREAMING_REQ_START BIT(1)
-#define VGXY61_REG_EXT_CLOCK   VGXY61_REG_32BIT(0x0220)
-#define VGXY61_REG_CLK_PLL_PREDIV  VGXY61_REG_8BIT(0x0224)
-#define VGXY61_REG_CLK_SYS_PLL_MULTVGXY61_REG_8BIT(0x0225)
-#define VGXY61_REG_GPIO_0_CTRL VGXY61_REG_8BIT(0x0236)
-#define VGXY61_REG_GPIO_1_CTRL VGXY61_REG_8BIT(0x0237)
-#define VGXY61_REG_GPIO_2_CTRL VGXY61_REG_8BIT(0x0238)
-#define VGXY61_REG_GPIO_3_CTRL VGXY61_REG_8BIT(0x0239)
-#define VGXY61_REG_SIGNALS_POLARITY_CTRL   VGXY61_REG_8BIT(0x023b)
-#define VGXY61_REG_LINE_LENGTH VGXY61_REG_16BIT(0x0300)
-#define VGXY61_REG_ORIENTATION VGXY61_REG_8BIT(0x0302)
-#define VGXY61_REG_VT_CTRL VGXY61_REG_8BIT(0x0304)
-#define VGXY61_REG_FORMAT_CTRL VGXY61_REG_8BIT(0x0305)
-#define VGXY61_REG_OIF_CTRLVGXY61_REG_16BIT(0x0306)
-#define VGXY61_REG_OIF_ROI0_CTRL   VGXY61_REG_8BIT(0x030a)
-#define VGXY61_REG_ROI0_STA

[git:media_tree/master] media: i2c: tvp5150: convert to use maple tree register cache

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

Subject: media: i2c: tvp5150: convert to use maple tree register cache
Author:  Bo Liu 
Date:Wed Jan 17 04:11:34 2024 +0100

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 9fc586cfdcd8..64b91aa3c82a 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1817,7 +1817,7 @@ static struct regmap_config tvp5150_config = {
.val_bits = 8,
.max_register = 0xff,
 
-   .cache_type = REGCACHE_RBTREE,
+   .cache_type = REGCACHE_MAPLE,
 
.rd_table = &tvp5150_readable_table,
.volatile_reg = tvp5150_volatile_reg,


[git:media_tree/master] media: i2c: imx415: Convert to new CCI register access helpers

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

Subject: media: i2c: imx415: Convert to new CCI register access helpers
Author:  Alexander Stein 
Date:Wed Jan 17 08:39:35 2024 +0100

Use the new common CCI register access helpers to replace the private
register access helpers in the imx415 driver.

Signed-off-by: Alexander Stein 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/i2c/Kconfig  |   1 +
 drivers/media/i2c/imx415.c | 407 +++--
 2 files changed, 170 insertions(+), 238 deletions(-)

---

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 9d9b52d93131..56f276b920ab 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -224,6 +224,7 @@ config VIDEO_IMX412
 config VIDEO_IMX415
tristate "Sony IMX415 sensor support"
depends on OF_GPIO
+   select V4L2_CCI_I2C
help
  This is a Video4Linux2 sensor driver for the Sony
  IMX415 camera.
diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c
index 1e5f20c3ed82..e52437fb5087 100644
--- a/drivers/media/i2c/imx415.c
+++ b/drivers/media/i2c/imx415.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -28,76 +29,65 @@
 
 #define IMX415_NUM_CLK_PARAM_REGS 11
 
-#define IMX415_REG_8BIT(n)   ((1 << 16) | (n))
-#define IMX415_REG_16BIT(n)  ((2 << 16) | (n))
-#define IMX415_REG_24BIT(n)  ((3 << 16) | (n))
-#define IMX415_REG_SIZE_SHIFT16
-#define IMX415_REG_ADDR_MASK 0x
-
-#define IMX415_MODE  IMX415_REG_8BIT(0x3000)
+#define IMX415_MODE  CCI_REG8(0x3000)
 #define IMX415_MODE_OPERATING(0)
 #define IMX415_MODE_STANDBY  BIT(0)
-#define IMX415_REGHOLD   IMX415_REG_8BIT(0x3001)
+#define IMX415_REGHOLD   CCI_REG8(0x3001)
 #define IMX415_REGHOLD_INVALID   (0)
 #define IMX415_REGHOLD_VALID BIT(0)
-#define IMX415_XMSTA IMX415_REG_8BIT(0x3002)
+#define IMX415_XMSTA CCI_REG8(0x3002)
 #define IMX415_XMSTA_START   (0)
 #define IMX415_XMSTA_STOPBIT(0)
-#define IMX415_BCWAIT_TIME   IMX415_REG_16BIT(0x3008)
-#define IMX415_CPWAIT_TIME   IMX415_REG_16BIT(0x300A)
-#define IMX415_WINMODE   IMX415_REG_8BIT(0x301C)
-#define IMX415_ADDMODE   IMX415_REG_8BIT(0x3022)
-#define IMX415_REVERSE   IMX415_REG_8BIT(0x3030)
+#define IMX415_BCWAIT_TIME   CCI_REG16_LE(0x3008)
+#define IMX415_CPWAIT_TIME   CCI_REG16_LE(0x300a)
+#define IMX415_WINMODE   CCI_REG8(0x301c)
+#define IMX415_ADDMODE   CCI_REG8(0x3022)
+#define IMX415_REVERSE   CCI_REG8(0x3030)
 #define IMX415_HREVERSE_SHIFT(0)
 #define IMX415_VREVERSE_SHIFTBIT(0)
-#define IMX415_ADBIT IMX415_REG_8BIT(0x3031)
-#define IMX415_MDBIT IMX415_REG_8BIT(0x3032)
-#define IMX415_SYS_MODE  IMX415_REG_8BIT(0x3033)
-#define IMX415_OUTSELIMX415_REG_8BIT(0x30C0)
-#define IMX415_DRV   IMX415_REG_8BIT(0x30C1)
-#define IMX415_VMAX  IMX415_REG_24BIT(0x3024)
-#define IMX415_HMAX  IMX415_REG_16BIT(0x3028)
-#define IMX415_SHR0  IMX415_REG_24BIT(0x3050)
-#define IMX415_GAIN_PCG_0IMX415_REG_16BIT(0x3090)
+#define IMX415_ADBIT CCI_REG8(0x3031)
+#define IMX415_MDBIT CCI_REG8(0x3032)
+#define IMX415_SYS_MODE  CCI_REG8(0x3033)
+#define IMX415_OUTSELCCI_REG8(0x30c0)
+#define IMX415_DRV   CCI_REG8(0x30c1)
+#define IMX415_VMAX  CCI_REG24_LE(0x3024)
+#define IMX415_HMAX  CCI_REG16_LE(0x3028)
+#define IMX415_SHR0  CCI_REG24_LE(0x3050)
+#define IMX415_GAIN_PCG_0CCI_REG16_LE(0x3090)
 #define IMX415_AGAIN_MIN 0
 #define IMX415_AGAIN_MAX 100
 #define IMX415_AGAIN_STEP1
-#define IMX415_BLKLEVEL  IMX415_REG_16BIT(0x30E2)
+#define IMX415_BLKLEVEL  CCI_REG16_LE(0x30e2)
 #define IMX415_BLKLEVEL_DEFAULT  50
-#define IMX415_TPG_EN_DUOUT  IMX415_REG_8BIT(0x30E4)
-#define IMX415_TPG_PATSEL_DUOUT  IMX415_REG_8BIT(0x30E6)
-#define IMX415_TPG_COLORWIDTHIMX415_REG_8BIT(0x30E8)
-#define IMX415_TESTCLKEN_MIPIIMX415_REG_8BIT(0x3110)
-#define IMX415_INCKSEL1  IMX415_REG_8BIT(0x3115)
-#define IMX415_INCKSEL2  IMX415_REG_8BIT(0x3116)
-#define IMX415_INCKSEL3  IMX415_REG_16BIT(0x3118)
-#define IMX415_INCKSEL4  IMX415_REG_16BIT(0x311A)
-#define IMX415_INCKSEL5  IMX415_REG_8BIT(0x311E)
-#define IMX415_DIG_CLP_MODE  IMX415_REG_8BIT(0x32C8)
-#define IMX415_WRJ_OPEN  IMX415_REG_8BIT(0x3390)
-#define IMX415_SENSOR_INFO   IMX415_REG_16BIT(0x3F12)
-#define IMX415_SENSOR_INFO_MASK  0xFFF
+#define IMX415_TPG_EN_DUOUT  CCI_REG8(0x30e4)

[git:media_tree/master] media: i2c: imx274: convert to use maple tree register cache

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

Subject: media: i2c: imx274: convert to use maple tree register cache
Author:  Bo Liu 
Date:Wed Jan 17 04:08:25 2024 +0100

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c
index 352da68b8b41..3800de974e8a 100644
--- a/drivers/media/i2c/imx274.c
+++ b/drivers/media/i2c/imx274.c
@@ -151,7 +151,7 @@ struct reg_8 {
 static const struct regmap_config imx274_regmap_config = {
.reg_bits = 16,
.val_bits = 8,
-   .cache_type = REGCACHE_RBTREE,
+   .cache_type = REGCACHE_MAPLE,
 };
 
 /*


[git:media_tree/master] media: i2c: imx214: convert to use maple tree register cache

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

Subject: media: i2c: imx214: convert to use maple tree register cache
Author:  Bo Liu 
Date:Wed Jan 17 04:07:30 2024 +0100

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
index b148b1bd2bc3..10b6ad66d126 100644
--- a/drivers/media/i2c/imx214.c
+++ b/drivers/media/i2c/imx214.c
@@ -968,7 +968,7 @@ static const struct v4l2_subdev_internal_ops 
imx214_internal_ops = {
 static const struct regmap_config sensor_regmap_config = {
.reg_bits = 16,
.val_bits = 8,
-   .cache_type = REGCACHE_RBTREE,
+   .cache_type = REGCACHE_MAPLE,
 };
 
 static int imx214_get_regulators(struct device *dev, struct imx214 *imx214)


[git:media_tree/master] media: arm64: dts: st: add video encoder support to stm32mp255

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

Subject: media: arm64: dts: st: add video encoder support to stm32mp255
Author:  Hugues Fruchet 
Date:Wed Jan 10 11:46:42 2024 +0100

Add VENC hardware video encoder support to STM32MP255.

Signed-off-by: Hugues Fruchet 
Signed-off-by: Mauro Carvalho Chehab 

 arch/arm64/boot/dts/st/stm32mp251.dtsi | 6 ++
 arch/arm64/boot/dts/st/stm32mp255.dtsi | 7 +++
 2 files changed, 13 insertions(+)

---

diff --git a/arch/arm64/boot/dts/st/stm32mp251.dtsi 
b/arch/arm64/boot/dts/st/stm32mp251.dtsi
index 8fc7e9199499..5dd4f3580a60 100644
--- a/arch/arm64/boot/dts/st/stm32mp251.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp251.dtsi
@@ -58,6 +58,12 @@
compatible = "fixed-clock";
clock-frequency = <2>;
};
+
+   ck_icn_p_venc: ck-icn-p-venc {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <2>;
+   };
};
 
firmware {
diff --git a/arch/arm64/boot/dts/st/stm32mp255.dtsi 
b/arch/arm64/boot/dts/st/stm32mp255.dtsi
index aea5096dac3c..17f197c5b22b 100644
--- a/arch/arm64/boot/dts/st/stm32mp255.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp255.dtsi
@@ -14,6 +14,13 @@
interrupts = ;
clocks = <&ck_icn_p_vdec>;
};
+
+   venc: venc@480e {
+   compatible = "st,stm32mp25-venc";
+   reg = <0x480e 0x800>;
+   interrupts = ;
+   clocks = <&ck_icn_ls_mcu>;
+   };
};
};
 };


[git:media_tree/master] media: i2c: mt9v032: convert to use maple tree register cache

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

Subject: media: i2c: mt9v032: convert to use maple tree register cache
Author:  Bo Liu 
Date:Wed Jan 17 04:11:05 2024 +0100

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 3ca76eeae7ff..6dfbd1c56c22 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -988,7 +988,7 @@ static const struct regmap_config mt9v032_regmap_config = {
.reg_bits = 8,
.val_bits = 16,
.max_register = 0xff,
-   .cache_type = REGCACHE_RBTREE,
+   .cache_type = REGCACHE_MAPLE,
 };
 
 /* 
-


[git:media_tree/master] media: arm64: dts: st: add video decoder support to stm32mp255

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

Subject: media: arm64: dts: st: add video decoder support to stm32mp255
Author:  Hugues Fruchet 
Date:Wed Jan 10 11:46:41 2024 +0100

Add VDEC hardware video decoder support to STM32MP255.

Signed-off-by: Hugues Fruchet 
Signed-off-by: Mauro Carvalho Chehab 

 arch/arm64/boot/dts/st/stm32mp251.dtsi |  6 ++
 arch/arm64/boot/dts/st/stm32mp255.dtsi | 10 ++
 2 files changed, 16 insertions(+)

---

diff --git a/arch/arm64/boot/dts/st/stm32mp251.dtsi 
b/arch/arm64/boot/dts/st/stm32mp251.dtsi
index 96859d098ef8..8fc7e9199499 100644
--- a/arch/arm64/boot/dts/st/stm32mp251.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp251.dtsi
@@ -52,6 +52,12 @@
compatible = "fixed-clock";
clock-frequency = <2>;
};
+
+   ck_icn_p_vdec: ck-icn-p-vdec {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <2>;
+   };
};
 
firmware {
diff --git a/arch/arm64/boot/dts/st/stm32mp255.dtsi 
b/arch/arm64/boot/dts/st/stm32mp255.dtsi
index e6fa596211f5..aea5096dac3c 100644
--- a/arch/arm64/boot/dts/st/stm32mp255.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp255.dtsi
@@ -6,4 +6,14 @@
 #include "stm32mp253.dtsi"
 
 / {
+   soc@0 {
+   rifsc: rifsc-bus@4208 {
+   vdec: vdec@480d {
+   compatible = "st,stm32mp25-vdec";
+   reg = <0x480d 0x3c8>;
+   interrupts = ;
+   clocks = <&ck_icn_p_vdec>;
+   };
+   };
+   };
 };


[git:media_tree/master] media: i2c: max2175: convert to use maple tree register cache

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

Subject: media: i2c: max2175: convert to use maple tree register cache
Author:  Bo Liu 
Date:Wed Jan 17 04:10:24 2024 +0100

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/media/i2c/max2175.c b/drivers/media/i2c/max2175.c
index 70c2a2948fd4..cd73d2096ae4 100644
--- a/drivers/media/i2c/max2175.c
+++ b/drivers/media/i2c/max2175.c
@@ -257,7 +257,7 @@ static const struct regmap_config max2175_regmap_config = {
.reg_defaults = max2175_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(max2175_reg_defaults),
.volatile_table = &max2175_volatile_regs,
-   .cache_type = REGCACHE_RBTREE,
+   .cache_type = REGCACHE_MAPLE,
 };
 
 struct max2175 {


[git:media_tree/master] media: hantro: add support for STM32MP25 VDEC

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

Subject: media: hantro: add support for STM32MP25 VDEC
Author:  Hugues Fruchet 
Date:Wed Jan 10 11:46:39 2024 +0100

Add support for STM32MP25 VDEC video hardware decoder.
Support of H264/VP8 decoding.
No post-processor support.
VDEC has its own reset/clock/irq.

Successfully tested up to full HD.

Reviewed-by: Nicolas Dufresne 
Signed-off-by: Hugues Fruchet 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/platform/verisilicon/Kconfig | 14 +++-
 drivers/media/platform/verisilicon/Makefile|  3 +
 drivers/media/platform/verisilicon/hantro_drv.c|  3 +
 drivers/media/platform/verisilicon/hantro_hw.h |  1 +
 .../media/platform/verisilicon/stm32mp25_vpu_hw.c  | 96 ++
 5 files changed, 114 insertions(+), 3 deletions(-)

---

diff --git a/drivers/media/platform/verisilicon/Kconfig 
b/drivers/media/platform/verisilicon/Kconfig
index 24b927d8f182..9a34d14c6e40 100644
--- a/drivers/media/platform/verisilicon/Kconfig
+++ b/drivers/media/platform/verisilicon/Kconfig
@@ -4,7 +4,7 @@ comment "Verisilicon media platform drivers"
 
 config VIDEO_HANTRO
tristate "Hantro VPU driver"
-   depends on ARCH_MXC || ARCH_ROCKCHIP || ARCH_AT91 || ARCH_SUNXI || 
COMPILE_TEST
+   depends on ARCH_MXC || ARCH_ROCKCHIP || ARCH_AT91 || ARCH_SUNXI || 
ARCH_STM32 || COMPILE_TEST
depends on V4L_MEM2MEM_DRIVERS
depends on VIDEO_DEV
select MEDIA_CONTROLLER
@@ -15,8 +15,8 @@ config VIDEO_HANTRO
select V4L2_VP9
help
  Support for the Hantro IP based Video Processing Units present on
- Rockchip and NXP i.MX8M SoCs, which accelerate video and image
- encoding and decoding.
+ Rockchip, NXP i.MX8M and STM32MP25 SoCs, which accelerate video
+ and image encoding and decoding.
  To compile this driver as a module, choose M here: the module
  will be called hantro-vpu.
 
@@ -51,3 +51,11 @@ config VIDEO_HANTRO_SUNXI
default y
help
  Enable support for H6 SoC.
+
+config VIDEO_HANTRO_STM32MP25
+   bool "Hantro STM32MP25 support"
+   depends on VIDEO_HANTRO
+   depends on ARCH_STM32 || COMPILE_TEST
+   default y
+   help
+ Enable support for STM32MP25 SoCs.
diff --git a/drivers/media/platform/verisilicon/Makefile 
b/drivers/media/platform/verisilicon/Makefile
index 6ad2ef885920..eb38a1833b02 100644
--- a/drivers/media/platform/verisilicon/Makefile
+++ b/drivers/media/platform/verisilicon/Makefile
@@ -39,3 +39,6 @@ hantro-vpu-$(CONFIG_VIDEO_HANTRO_ROCKCHIP) += \
 
 hantro-vpu-$(CONFIG_VIDEO_HANTRO_SUNXI) += \
sunxi_vpu_hw.o
+
+hantro-vpu-$(CONFIG_VIDEO_HANTRO_STM32MP25) += \
+   stm32mp25_vpu_hw.o
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c 
b/drivers/media/platform/verisilicon/hantro_drv.c
index db3df6cc4513..fe8e2240324c 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -735,6 +735,9 @@ static const struct of_device_id of_hantro_match[] = {
 #endif
 #ifdef CONFIG_VIDEO_HANTRO_SUNXI
{ .compatible = "allwinner,sun50i-h6-vpu-g2", .data = 
&sunxi_vpu_variant, },
+#endif
+#ifdef CONFIG_VIDEO_HANTRO_STM32MP25
+   { .compatible = "st,stm32mp25-vdec", .data = &stm32mp25_vdec_variant, },
 #endif
{ /* sentinel */ }
 };
diff --git a/drivers/media/platform/verisilicon/hantro_hw.h 
b/drivers/media/platform/verisilicon/hantro_hw.h
index 9aec8a79acdc..0b4806f67630 100644
--- a/drivers/media/platform/verisilicon/hantro_hw.h
+++ b/drivers/media/platform/verisilicon/hantro_hw.h
@@ -408,6 +408,7 @@ extern const struct hantro_variant rk3568_vpu_variant;
 extern const struct hantro_variant rk3588_vpu981_variant;
 extern const struct hantro_variant sama5d4_vdec_variant;
 extern const struct hantro_variant sunxi_vpu_variant;
+extern const struct hantro_variant stm32mp25_vdec_variant;
 
 extern const struct hantro_postproc_ops hantro_g1_postproc_ops;
 extern const struct hantro_postproc_ops hantro_g2_postproc_ops;
diff --git a/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c 
b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
new file mode 100644
index ..6af6edcb6650
--- /dev/null
+++ b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
@@ -0,0 +1,96 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * STM32MP25 video codec driver
+ *
+ * Copyright (C) STMicroelectronics SA 2024
+ * Authors: Hugues Fruchet 
+ *  for STMicroelectronics.
+ *
+ */
+
+#include "hantro.h"
+
+/*
+ * Supported formats.
+ */
+
+static const struct hantro_fmt stm32mp25_vdec_fmts[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_NV12,
+   .codec_mode = HANTRO_MODE_NONE,
+   .frmsize = {
+   .min_width = FMT_MIN_WIDTH,
+   .max_width = FMT_FHD_WIDTH,
+   .s

[git:media_tree/master] media: i2c: isl7998x: convert to use maple tree register cache

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

Subject: media: i2c: isl7998x: convert to use maple tree register cache
Author:  Bo Liu 
Date:Wed Jan 17 04:09:10 2024 +0100

The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.

Signed-off-by: Bo Liu 
Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/media/i2c/isl7998x.c b/drivers/media/i2c/isl7998x.c
index 89e13ebbce0c..c7089035bbc1 100644
--- a/drivers/media/i2c/isl7998x.c
+++ b/drivers/media/i2c/isl7998x.c
@@ -1337,7 +1337,7 @@ static const struct regmap_config isl7998x_regmap = {
.rd_table   = &isl7998x_readable_table,
.wr_table   = &isl7998x_writeable_table,
.volatile_table = &isl7998x_volatile_table,
-   .cache_type = REGCACHE_RBTREE,
+   .cache_type = REGCACHE_MAPLE,
 };
 
 static int isl7998x_mc_init(struct isl7998x *isl7998x)


[git:media_tree/master] media: platform: mtk-mdp3: add mt8195 shared memory configurations

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

Subject: media: platform: mtk-mdp3: add mt8195 shared memory configurations
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:36 2023 +0100

The configuration of the MT8195 components in the shared memory
is defined in the header file "mdp_sm_mt8195.h".

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mdp_sm_mt8195.h   | 283 +
 drivers/media/platform/mediatek/mdp3/mtk-img-ipi.h |   3 +
 2 files changed, 286 insertions(+)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mdp_sm_mt8195.h 
b/drivers/media/platform/mediatek/mdp3/mdp_sm_mt8195.h
new file mode 100644
index ..b09f48222d24
--- /dev/null
+++ b/drivers/media/platform/mediatek/mdp3/mdp_sm_mt8195.h
@@ -0,0 +1,283 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2023 MediaTek Inc.
+ * Author: Ping-Hsun Wu 
+ */
+
+#ifndef __MDP_SM_MT8195_H__
+#define __MDP_SM_MT8195_H__
+
+#include "mtk-mdp3-type.h"
+
+/*
+ * ISP-MDP generic output information
+ * MD5 of the target SCP prebuild:
+ * a49ec487e458b5971880f1b63dc2a9d5
+ */
+
+#define IMG_MAX_SUBFRAMES_8195 20
+
+struct img_comp_frame_8195 {
+   u32 output_disable;
+   u32 bypass;
+   u32 in_width;
+   u32 in_height;
+   u32 out_width;
+   u32 out_height;
+   struct img_crop crop;
+   u32 in_total_width;
+   u32 out_total_width;
+} __packed;
+
+struct img_comp_subfrm_8195 {
+   u32 tile_disable;
+   struct img_region in;
+   struct img_region out;
+   struct img_offset luma;
+   struct img_offset chroma;
+   s32 out_vertical; /* Output vertical index */
+   s32 out_horizontal; /* Output horizontal index */
+} __packed;
+
+struct mdp_rdma_subfrm_8195 {
+   u32 offset[IMG_MAX_PLANES];
+   u32 offset_0_p;
+   u32 src;
+   u32 clip;
+   u32 clip_ofst;
+   u32 in_tile_xleft;
+   u32 in_tile_ytop;
+} __packed;
+
+struct mdp_rdma_data_8195 {
+   u32 src_ctrl;
+   u32 comp_ctrl;
+   u32 control;
+   u32 iova[IMG_MAX_PLANES];
+   u32 iova_end[IMG_MAX_PLANES];
+   u32 mf_bkgd;
+   u32 mf_bkgd_in_pxl;
+   u32 sf_bkgd;
+   u32 ufo_dec_y;
+   u32 ufo_dec_c;
+   u32 transform;
+   u32 dmabuf_con0;
+   u32 ultra_th_high_con0;
+   u32 ultra_th_low_con0;
+   u32 dmabuf_con1;
+   u32 ultra_th_high_con1;
+   u32 ultra_th_low_con1;
+   u32 dmabuf_con2;
+   u32 ultra_th_high_con2;
+   u32 ultra_th_low_con2;
+   u32 dmabuf_con3;
+   struct mdp_rdma_subfrm_8195 subfrms[IMG_MAX_SUBFRAMES_8195];
+} __packed;
+
+struct mdp_fg_subfrm_8195 {
+   u32 info_0;
+   u32 info_1;
+} __packed;
+
+struct mdp_fg_data_8195 {
+   u32 ctrl_0;
+   u32 ck_en;
+   struct mdp_fg_subfrm_8195 subfrms[IMG_MAX_SUBFRAMES_8195];
+} __packed;
+
+struct mdp_hdr_subfrm_8195 {
+   u32 win_size;
+   u32 src;
+   u32 clip_ofst0;
+   u32 clip_ofst1;
+   u32 hist_ctrl_0;
+   u32 hist_ctrl_1;
+   u32 hdr_top;
+   u32 hist_addr;
+} __packed;
+
+struct mdp_hdr_data_8195 {
+   u32 top;
+   u32 relay;
+   struct mdp_hdr_subfrm_8195   subfrms[IMG_MAX_SUBFRAMES_8195];
+} __packed;
+
+struct mdp_aal_subfrm_8195 {
+   u32 src;
+   u32 clip;
+   u32 clip_ofst;
+} __packed;
+
+struct mdp_aal_data_8195 {
+   u32 cfg_main;
+   u32 cfg;
+   struct mdp_aal_subfrm_8195   subfrms[IMG_MAX_SUBFRAMES_8195];
+} __packed;
+
+struct mdp_rsz_subfrm_8195 {
+   u32 control2;
+   u32 src;
+   u32 clip;
+   u32 hdmirx_en;
+   u32 luma_h_int_ofst;
+   u32 luma_h_sub_ofst;
+   u32 luma_v_int_ofst;
+   u32 luma_v_sub_ofst;
+   u32 chroma_h_int_ofst;
+   u32 chroma_h_sub_ofst;
+   u32 rsz_switch;
+   u32 merge_cfg;
+} __packed;
+
+struct mdp_rsz_data_8195 {
+   u32 coeff_step_x;
+   u32 coeff_step_y;
+   u32 control1;
+   u32 control2;
+   u32 etc_control;
+   u32 prz_enable;
+   u32 ibse_softclip;
+   u32 tap_adapt;
+   u32 ibse_gaincontrol1;
+   u32 ibse_gaincontrol2;
+   u32 ibse_ylevel_1;
+   u32 ibse_ylevel_2;
+   u32 ibse_ylevel_3;
+   u32 ibse_ylevel_4;
+   u32 ibse_ylevel_5;
+   struct mdp_rsz_subfrm_8195 subfrms[IMG_MAX_SUBFRAMES_8195];
+} __packed;
+
+struct mdp_tdshp_subfrm_8195 {
+   u32 src;
+   u32 clip;
+   u32 clip_ofst;
+   u32 hist_cfg_0;
+   u32 hist_cfg_1;
+} __packed;
+
+struct mdp_tdshp_data_8195 {
+   u32 cfg;
+   struct mdp_tdshp_subfrm_8195 subfrms[IMG_MAX_SUBFRAMES_8195];
+} __packed;
+
+struct mdp_color_subfrm_8195 {
+   u32 in_hsize;
+   u32 in_vsize;
+} __packed;
+
+struct mdp_color_data_8195 {
+   u32 start;
+   struct mdp_color_subfrm_8195 subfrms[IMG_MAX_SUBFRAMES_8195];
+} __p

[git:media_tree/master] media: Documentation: Rework CCS driver documentation

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

Subject: media: Documentation: Rework CCS driver documentation
Author:  Sakari Ailus 
Date:Fri Jan 5 11:59:22 2024 +0100

Drop duplicated UAPI specific portions of the CCS (kernel) documentation
and fix a spelling error in UAPI documentation previously fixed in driver
documentation.

Also add references both ways.

Signed-off-by: Sakari Ailus 
Signed-off-by: Mauro Carvalho Chehab 

 Documentation/driver-api/media/drivers/ccs/ccs.rst | 53 ++
 Documentation/userspace-api/media/drivers/ccs.rst  |  6 ++-
 2 files changed, 10 insertions(+), 49 deletions(-)

---

diff --git a/Documentation/driver-api/media/drivers/ccs/ccs.rst 
b/Documentation/driver-api/media/drivers/ccs/ccs.rst
index 776eec72bc80..5d4451339b7f 100644
--- a/Documentation/driver-api/media/drivers/ccs/ccs.rst
+++ b/Documentation/driver-api/media/drivers/ccs/ccs.rst
@@ -2,59 +2,16 @@
 
 .. include:: 
 
+.. _media-ccs-driver:
+
 MIPI CCS camera sensor driver
 =
 
 The MIPI CCS camera sensor driver is a generic driver for `MIPI CCS
 `_ compliant
-camera sensors. It exposes three sub-devices representing the pixel array,
-the binner and the scaler.
-
-As the capabilities of individual devices vary, the driver exposes
-interfaces based on the capabilities that exist in hardware.
-
-Pixel Array sub-device
---
-
-The pixel array sub-device represents the camera sensor's pixel matrix, as well
-as analogue crop functionality present in many compliant devices. The analogue
-crop is configured using the ``V4L2_SEL_TGT_CROP`` on the source pad (0) of the
-entity. The size of the pixel matrix can be obtained by getting the
-``V4L2_SEL_TGT_NATIVE_SIZE`` target.
-
-Binner
---
-
-The binner sub-device represents the binning functionality on the sensor. For
-that purpose, selection target ``V4L2_SEL_TGT_COMPOSE`` is supported on the
-sink pad (0).
-
-Additionally, if a device has no scaler or digital crop functionality, the
-source pad (1) exposes another digital crop selection rectangle that can only
-crop at the end of the lines and frames.
-
-Scaler
---
-
-The scaler sub-device represents the digital crop and scaling functionality of
-the sensor. The V4L2 selection target ``V4L2_SEL_TGT_CROP`` is used to
-configure the digital crop on the sink pad (0) when digital crop is supported.
-Scaling is configured using selection target ``V4L2_SEL_TGT_COMPOSE`` on the
-sink pad (0) as well.
-
-Additionally, if the scaler sub-device exists, its source pad (1) exposes
-another digital crop selection rectangle that can only crop at the end of the
-lines and frames.
-
-Digital and analogue crop
--
-
-Digital crop functionality is referred to as cropping that effectively works by
-dropping some data on the floor. Analogue crop, on the other hand, means that
-the cropped information is never retrieved. In case of camera sensors, the
-analogue data is never read from the pixel matrix that are outside the
-configured selection rectangle that designates crop. The difference has an
-effect in device timing and likely also in power consumption.
+camera sensors.
+
+Also see :ref:`the CCS driver UAPI documentation `.
 
 CCS static data
 ---
diff --git a/Documentation/userspace-api/media/drivers/ccs.rst 
b/Documentation/userspace-api/media/drivers/ccs.rst
index 161cb65f4d98..03015b33d5ab 100644
--- a/Documentation/userspace-api/media/drivers/ccs.rst
+++ b/Documentation/userspace-api/media/drivers/ccs.rst
@@ -2,6 +2,8 @@
 
 .. include:: 
 
+.. _media-ccs-uapi:
+
 MIPI CCS camera sensor driver
 =
 
@@ -13,6 +15,8 @@ the binner and the scaler.
 As the capabilities of individual devices vary, the driver exposes
 interfaces based on the capabilities that exist in hardware.
 
+Also see :ref:`the CCS driver kernel documentation `.
+
 Pixel Array sub-device
 --
 
@@ -30,7 +34,7 @@ that purpose, selection target ``V4L2_SEL_TGT_COMPOSE`` is 
supported on the
 sink pad (0).
 
 Additionally, if a device has no scaler or digital crop functionality, the
-source pad (1) expses another digital crop selection rectangle that can only
+source pad (1) exposes another digital crop selection rectangle that can only
 crop at the end of the lines and frames.
 
 Scaler


[git:media_tree/master] media: hantro: add support for STM32MP25 VENC

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

Subject: media: hantro: add support for STM32MP25 VENC
Author:  Hugues Fruchet 
Date:Wed Jan 10 11:46:40 2024 +0100

Add support for STM32MP25 VENC video hardware encoder.
Support of JPEG encoding.
VENC has its own reset/clock/irq.

Reviewed-by: Nicolas Dufresne 
Signed-off-by: Hugues Fruchet 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/platform/verisilicon/hantro_drv.c|  1 +
 drivers/media/platform/verisilicon/hantro_hw.h |  1 +
 .../media/platform/verisilicon/stm32mp25_vpu_hw.c  | 90 ++
 3 files changed, 92 insertions(+)

---

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c 
b/drivers/media/platform/verisilicon/hantro_drv.c
index fe8e2240324c..34b123dafd89 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -738,6 +738,7 @@ static const struct of_device_id of_hantro_match[] = {
 #endif
 #ifdef CONFIG_VIDEO_HANTRO_STM32MP25
{ .compatible = "st,stm32mp25-vdec", .data = &stm32mp25_vdec_variant, },
+   { .compatible = "st,stm32mp25-venc", .data = &stm32mp25_venc_variant, },
 #endif
{ /* sentinel */ }
 };
diff --git a/drivers/media/platform/verisilicon/hantro_hw.h 
b/drivers/media/platform/verisilicon/hantro_hw.h
index 0b4806f67630..7737320cc8cc 100644
--- a/drivers/media/platform/verisilicon/hantro_hw.h
+++ b/drivers/media/platform/verisilicon/hantro_hw.h
@@ -409,6 +409,7 @@ extern const struct hantro_variant rk3588_vpu981_variant;
 extern const struct hantro_variant sama5d4_vdec_variant;
 extern const struct hantro_variant sunxi_vpu_variant;
 extern const struct hantro_variant stm32mp25_vdec_variant;
+extern const struct hantro_variant stm32mp25_venc_variant;
 
 extern const struct hantro_postproc_ops hantro_g1_postproc_ops;
 extern const struct hantro_postproc_ops hantro_g2_postproc_ops;
diff --git a/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c 
b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
index 6af6edcb6650..833821120b20 100644
--- a/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
+++ b/drivers/media/platform/verisilicon/stm32mp25_vpu_hw.c
@@ -9,6 +9,8 @@
  */
 
 #include "hantro.h"
+#include "hantro_jpeg.h"
+#include "hantro_h1_regs.h"
 
 /*
  * Supported formats.
@@ -55,6 +57,67 @@ static const struct hantro_fmt stm32mp25_vdec_fmts[] = {
},
 };
 
+static const struct hantro_fmt stm32mp25_venc_fmts[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_YUV420M,
+   .codec_mode = HANTRO_MODE_NONE,
+   .enc_fmt = ROCKCHIP_VPU_ENC_FMT_YUV420P,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_NV12M,
+   .codec_mode = HANTRO_MODE_NONE,
+   .enc_fmt = ROCKCHIP_VPU_ENC_FMT_YUV420SP,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_YUYV,
+   .codec_mode = HANTRO_MODE_NONE,
+   .enc_fmt = ROCKCHIP_VPU_ENC_FMT_YUYV422,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_UYVY,
+   .codec_mode = HANTRO_MODE_NONE,
+   .enc_fmt = ROCKCHIP_VPU_ENC_FMT_UYVY422,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_JPEG,
+   .codec_mode = HANTRO_MODE_JPEG_ENC,
+   .max_depth = 2,
+   .header_size = JPEG_HEADER_SIZE,
+   .frmsize = {
+   .min_width = 96,
+   .max_width = FMT_4K_WIDTH,
+   .step_width = MB_DIM,
+   .min_height = 96,
+   .max_height = FMT_4K_HEIGHT,
+   .step_height = MB_DIM,
+   },
+   },
+};
+
+static irqreturn_t stm32mp25_venc_irq(int irq, void *dev_id)
+{
+   struct hantro_dev *vpu = dev_id;
+   enum vb2_buffer_state state;
+   u32 status;
+
+   status = vepu_read(vpu, H1_REG_INTERRUPT);
+   state = (status & H1_REG_INTERRUPT_FRAME_RDY) ?
+   VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR;
+
+   vepu_write(vpu, H1_REG_INTERRUPT_BIT, H1_REG_INTERRUPT);
+
+   hantro_irq_done(vpu, state);
+
+   return IRQ_HANDLED;
+}
+
+static void stm32mp25_venc_reset(struct hantro_ctx *ctx)
+{
+   struct hantro_dev *vpu = ctx->dev;
+
+   reset_control_reset(vpu->resets);
+}
+
 /*
  * Supported codec ops.
  */
@@ -74,6 +137,14 @@ static const struct hantro_codec_ops 
stm32mp25_vdec_codec_ops[] = {
},
 };
 
+static const struct hantro_codec_ops stm32mp25_venc_codec_ops[] = {
+   [HANTRO_MODE_JPEG_ENC] = {
+   .run = hantro_h1_jpeg_enc_run,
+   .reset = stm32mp25_venc_reset,
+   .done = hantro_h1_jpeg_enc_done,
+   },
+};
+
 /*
  * Variants.
  */
@@ -94,3 +165,22 @@ const struct hantro_variant stm32mp25_vdec_variant = {
.clk_names = stm32mp25_vdec_clk_names,
.num_clocks = ARRAY_SIZE(stm32mp25_vdec_clk_names),
 };
+
+static const struct han

[git:media_tree/master] media: dt-bindings: media: Document STM32MP25 VDEC & VENC video codecs

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

Subject: media: dt-bindings: media: Document STM32MP25 VDEC & VENC video codecs
Author:  Hugues Fruchet 
Date:Wed Jan 10 11:46:38 2024 +0100

Add STM32MP25 VDEC video decoder & VENC video encoder bindings.

Reviewed-by: Krzysztof Kozlowski 
Signed-off-by: Hugues Fruchet 
Signed-off-by: Mauro Carvalho Chehab 

 .../bindings/media/st,stm32mp25-video-codec.yaml   | 49 ++
 1 file changed, 49 insertions(+)

---

diff --git 
a/Documentation/devicetree/bindings/media/st,stm32mp25-video-codec.yaml 
b/Documentation/devicetree/bindings/media/st,stm32mp25-video-codec.yaml
new file mode 100644
index ..b8611bc8756c
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/st,stm32mp25-video-codec.yaml
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/st,stm32mp25-video-codec.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STMicroelectronics STM32MP25 VDEC video decoder & VENC video encoder
+
+maintainers:
+  - Hugues Fruchet 
+
+description:
+  The STMicroelectronics STM32MP25 SOCs embeds a VDEC video hardware
+  decoder peripheral based on Verisilicon VC8000NanoD IP (former Hantro G1)
+  and a VENC video hardware encoder peripheral based on Verisilicon
+  VC8000NanoE IP (former Hantro H1).
+
+properties:
+  compatible:
+enum:
+  - st,stm32mp25-vdec
+  - st,stm32mp25-venc
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  clocks:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+video-codec@580d {
+compatible = "st,stm32mp25-vdec";
+reg = <0x580d 0x3c8>;
+interrupts = ;
+clocks = <&ck_icn_p_vdec>;
+};


[git:media_tree/master] media: platform: mtk-mdp3: add support for blending multiple components

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

Subject: media: platform: mtk-mdp3: add support for blending multiple components
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:34 2023 +0100

Certain chips can combine several components to form complex virtual
units with advanced functions.
These components require simultaneous configuration of their MODs and
clocks.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c   | 10 +++-
 .../media/platform/mediatek/mdp3/mtk-mdp3-comp.c   | 29 --
 .../media/platform/mediatek/mdp3/mtk-mdp3-comp.h   |  7 ++
 3 files changed, 43 insertions(+), 3 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index a81caf5f472c..f0c5f5abeb23 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -110,17 +110,25 @@ static int mdp_path_subfrm_require(const struct mdp_path 
*path,
/* Set mutex mod */
for (index = 0; index < num_comp; index++) {
s32 inner_id = MDP_COMP_NONE;
+   const u32 *mutex_idx;
+   const struct mdp_comp_blend *b;
 
if (CFG_CHECK(MT8183, p_id))
inner_id = CFG_GET(MT8183, path->config, 
components[index].type);
if (mdp_cfg_comp_is_dummy(path->mdp_dev, inner_id))
continue;
+
ctx = &path->comps[index];
if (is_output_disabled(p_id, ctx->param, count))
continue;
+
+   mutex_idx = data->mdp_mutex_table_idx;
id = ctx->comp->public_id;
-   mtk_mutex_write_mod(mutex, data->mdp_mutex_table_idx[id], 
false);
+   mtk_mutex_write_mod(mutex, mutex_idx[id], false);
 
+   b = &data->comp_data[id].blend;
+   if (b && b->aid_mod)
+   mtk_mutex_write_mod(mutex, mutex_idx[b->b_id], false);
}
 
mtk_mutex_write_sof(mutex, MUTEX_SOF_IDX_SINGLE_MODE);
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
index ed6092e1666f..e97630b7867c 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
@@ -864,12 +864,26 @@ int mdp_comp_clocks_on(struct device *dev, struct 
mdp_comp *comps, int num)
int i, ret;
 
for (i = 0; i < num; i++) {
+   struct mdp_dev *m = comps[i].mdp_dev;
+   enum mtk_mdp_comp_id id;
+   const struct mdp_comp_blend *b;
+
/* Bypass the dummy component*/
-   if (!comps[i].mdp_dev)
+   if (!m)
continue;
+
ret = mdp_comp_clock_on(dev, &comps[i]);
if (ret)
return ret;
+
+   id = comps[i].public_id;
+   b = &m->mdp_data->comp_data[id].blend;
+
+   if (b && b->aid_clk) {
+   ret = mdp_comp_clock_on(dev, m->comp[b->b_id]);
+   if (ret)
+   return ret;
+   }
}
 
return 0;
@@ -880,10 +894,21 @@ void mdp_comp_clocks_off(struct device *dev, struct 
mdp_comp *comps, int num)
int i;
 
for (i = 0; i < num; i++) {
+   struct mdp_dev *m = comps[i].mdp_dev;
+   enum mtk_mdp_comp_id id;
+   const struct mdp_comp_blend *b;
+
/* Bypass the dummy component*/
-   if (!comps[i].mdp_dev)
+   if (!m)
continue;
+
mdp_comp_clock_off(dev, &comps[i]);
+
+   id = comps[i].public_id;
+   b = &m->mdp_data->comp_data[id].blend;
+
+   if (b && b->aid_clk)
+   mdp_comp_clock_off(dev, m->comp[b->b_id]);
}
 }
 
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.h 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.h
index e6cbc6ab6bae..3e5d2da1c807 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.h
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.h
@@ -201,9 +201,16 @@ struct mdp_comp_info {
u32 dts_reg_ofst;
 };
 
+struct mdp_comp_blend {
+   enum mtk_mdp_comp_id b_id;
+   bool aid_mod;
+   bool aid_clk;
+};
+
 struct mdp_comp_data {
struct mdp_comp_match match;
struct mdp_comp_info info;
+   struct mdp_comp_blend blend;
 };
 
 struct mdp_comp_ops;


[git:media_tree/master] media: platform: mtk-mdp3: add support for parallel pipe to improve FPS

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

Subject: media: platform: mtk-mdp3: add support for parallel pipe to improve FPS
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:38 2023 +0100

In some chips, MDP3 has the ability to utilize two pipelines to
parallelly process a single frame.
To enable this feature, multiple CMDQ clients and packets need to
be configured at the same time.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mdp_cfg_data.c|   8 +
 .../media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c   | 188 +++--
 .../media/platform/mediatek/mdp3/mtk-mdp3-cmdq.h   |   1 +
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.c   |  18 +-
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.h   |  12 +-
 .../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c|  15 ++
 .../media/platform/mediatek/mdp3/mtk-mdp3-regs.c   |  18 ++
 .../media/platform/mediatek/mdp3/mtk-mdp3-regs.h   |   1 +
 .../media/platform/mediatek/mdp3/mtk-mdp3-vpu.c|   3 +-
 9 files changed, 208 insertions(+), 56 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c 
b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
index 9ee3931d31e3..ecca52b45307 100644
--- a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
+++ b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
@@ -1060,6 +1060,11 @@ static const struct mdp_pipe_info mt8195_pipe_info[] = {
[MDP_PIPE_VPP0_SOUT] = {MDP_PIPE_VPP0_SOUT, MDP_MM_SUBSYS_1, 5},
 };
 
+static const struct v4l2_rect mt8195_mdp_pp_criteria = {
+   .width = 1920,
+   .height = 1080,
+};
+
 const struct mtk_mdp_driver_data mt8183_mdp_driver_data = {
.mdp_plat_id = MT8183,
.mdp_con_res = 0x14001000,
@@ -1074,6 +1079,7 @@ const struct mtk_mdp_driver_data mt8183_mdp_driver_data = 
{
.def_limit = &mt8183_mdp_def_limit,
.pipe_info = mt8183_pipe_info,
.pipe_info_len = ARRAY_SIZE(mt8183_pipe_info),
+   .pp_used = MDP_PP_USED_1,
 };
 
 const struct mtk_mdp_driver_data mt8195_mdp_driver_data = {
@@ -1090,6 +1096,8 @@ const struct mtk_mdp_driver_data mt8195_mdp_driver_data = 
{
.def_limit = &mt8195_mdp_def_limit,
.pipe_info = mt8195_pipe_info,
.pipe_info_len = ARRAY_SIZE(mt8195_pipe_info),
+   .pp_criteria = &mt8195_mdp_pp_criteria,
+   .pp_used = MDP_PP_USED_2,
 };
 
 s32 mdp_cfg_get_id_inner(struct mdp_dev *mdp_dev, enum mtk_mdp_comp_id id)
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index 8114c288da9c..1d64bac34b90 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -55,6 +55,16 @@ static struct mtk_mutex *__get_mutex(const struct mdp_dev 
*mdp_dev,
return mdp_dev->mm_subsys[p->sub_id].mdp_mutex[p->mutex_id];
 }
 
+static u8 __get_pp_num(enum mdp_stream_type type)
+{
+   switch (type) {
+   case MDP_STREAM_TYPE_DUAL_BITBLT:
+   return MDP_PP_USED_2;
+   default:
+   return MDP_PP_USED_1;
+   }
+}
+
 static enum mdp_pipe_id __get_pipe(const struct mdp_dev *mdp_dev,
   enum mtk_mdp_comp_id id)
 {
@@ -92,6 +102,44 @@ static enum mdp_pipe_id __get_pipe(const struct mdp_dev 
*mdp_dev,
return pipe_id;
 }
 
+static struct img_config *__get_config_offset(struct mdp_dev *mdp,
+ struct mdp_cmdq_param *param,
+ u8 pp_idx)
+{
+   const int p_id = mdp->mdp_data->mdp_plat_id;
+   struct device *dev = &mdp->pdev->dev;
+   void *cfg_c, *cfg_n;
+   long bound = mdp->vpu.config_size;
+
+   if (pp_idx >= mdp->mdp_data->pp_used)
+   goto err_param;
+
+   if (CFG_CHECK(MT8183, p_id))
+   cfg_c = CFG_OFST(MT8183, param->config, pp_idx);
+   else if (CFG_CHECK(MT8195, p_id))
+   cfg_c = CFG_OFST(MT8195, param->config, pp_idx);
+   else
+   goto err_param;
+
+   if (CFG_CHECK(MT8183, p_id))
+   cfg_n = CFG_OFST(MT8183, param->config, pp_idx + 1);
+   else if (CFG_CHECK(MT8195, p_id))
+   cfg_n = CFG_OFST(MT8195, param->config, pp_idx + 1);
+   else
+   goto err_param;
+
+   if ((long)cfg_n - (long)mdp->vpu.config > bound) {
+   dev_err(dev, "config offset %ld OOB %ld\n", (long)cfg_n, bound);
+   cfg_c = ERR_PTR(-EFAULT);
+   }
+
+   return (struct img_config *)cfg_c;
+
+err_param:
+   cfg_c = ERR_PTR(-EINVAL);
+   return (struct img_config *)cfg_c;
+}
+
 static int mdp_path_subfrm_require(const struct mdp_path *path,
   struct mdp_cmdq_cmd *cmd,
   struct mdp_pipe_info *p, u32 count)
@

[git:media_tree/master] media: platform: mtk-mdp3: add mt8195 MDP3 component settings

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

Subject: media: platform: mtk-mdp3: add mt8195 MDP3 component settings
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:37 2023 +0100

Extend the component settings used in MT8195 MDP3.
Additionally, it is crucial to read all component settings in
a specific manner to ensure that shared memory data structure lengths
are aligned across different platforms.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c   |  57 ++
 .../media/platform/mediatek/mdp3/mtk-mdp3-comp.c   | 798 -
 2 files changed, 851 insertions(+), 4 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index f0c5f5abeb23..8114c288da9c 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -40,6 +40,10 @@ static bool is_output_disabled(int p_id, const struct 
img_compparam *param, u32
num = CFG_COMP(MT8183, param, num_subfrms);
dis_output = CFG_COMP(MT8183, param, frame.output_disable);
dis_tile = CFG_COMP(MT8183, param, frame.output_disable);
+   } else if (CFG_CHECK(MT8195, p_id)) {
+   num = CFG_COMP(MT8195, param, num_subfrms);
+   dis_output = CFG_COMP(MT8195, param, frame.output_disable);
+   dis_tile = CFG_COMP(MT8195, param, frame.output_disable);
}
 
return (count < num) ? (dis_output || dis_tile) : true;
@@ -101,6 +105,8 @@ static int mdp_path_subfrm_require(const struct mdp_path 
*path,
 
if (CFG_CHECK(MT8183, p_id))
num_comp = CFG_GET(MT8183, path->config, num_components);
+   else if (CFG_CHECK(MT8195, p_id))
+   num_comp = CFG_GET(MT8195, path->config, num_components);
 
/* Decide which mutex to use based on the current pipeline */
index = __get_pipe(path->mdp_dev, path->comps[0].comp->public_id);
@@ -115,6 +121,9 @@ static int mdp_path_subfrm_require(const struct mdp_path 
*path,
 
if (CFG_CHECK(MT8183, p_id))
inner_id = CFG_GET(MT8183, path->config, 
components[index].type);
+   else if (CFG_CHECK(MT8195, p_id))
+   inner_id = CFG_GET(MT8195, path->config, 
components[index].type);
+
if (mdp_cfg_comp_is_dummy(path->mdp_dev, inner_id))
continue;
 
@@ -156,12 +165,17 @@ static int mdp_path_subfrm_run(const struct mdp_path 
*path,
 
if (CFG_CHECK(MT8183, p_id))
num_comp = CFG_GET(MT8183, path->config, num_components);
+   else if (CFG_CHECK(MT8195, p_id))
+   num_comp = CFG_GET(MT8195, path->config, num_components);
 
/* Wait WROT SRAM shared to DISP RDMA */
/* Clear SOF event for each engine */
for (index = 0; index < num_comp; index++) {
if (CFG_CHECK(MT8183, p_id))
inner_id = CFG_GET(MT8183, path->config, 
components[index].type);
+   else if (CFG_CHECK(MT8195, p_id))
+   inner_id = CFG_GET(MT8195, path->config, 
components[index].type);
+
if (mdp_cfg_comp_is_dummy(path->mdp_dev, inner_id))
continue;
ctx = &path->comps[index];
@@ -180,6 +194,9 @@ static int mdp_path_subfrm_run(const struct mdp_path *path,
for (index = 0; index < num_comp; index++) {
if (CFG_CHECK(MT8183, p_id))
inner_id = CFG_GET(MT8183, path->config, 
components[index].type);
+   else if (CFG_CHECK(MT8195, p_id))
+   inner_id = CFG_GET(MT8195, path->config, 
components[index].type);
+
if (mdp_cfg_comp_is_dummy(path->mdp_dev, inner_id))
continue;
ctx = &path->comps[index];
@@ -202,6 +219,8 @@ static int mdp_path_ctx_init(struct mdp_dev *mdp, struct 
mdp_path *path)
 
if (CFG_CHECK(MT8183, p_id))
num_comp = CFG_GET(MT8183, path->config, num_components);
+   else if (CFG_CHECK(MT8195, p_id))
+   num_comp = CFG_GET(MT8195, path->config, num_components);
 
if (num_comp < 1)
return -EINVAL;
@@ -211,10 +230,15 @@ static int mdp_path_ctx_init(struct mdp_dev *mdp, struct 
mdp_path *path)
 
if (CFG_CHECK(MT8183, p_id))
inner_id = CFG_GET(MT8183, path->config, 
components[index].type);
+   else if (CFG_CHECK(MT8195, p_id))
+   inner_id = CFG_GET(MT8195, path->config, 
components[index].type);
+
if (mdp_cfg_comp_is_dummy(path->mdp_dev, inner_id))
continue;
if (CFG_CHECK(MT8183, p_id))
  

[git:media_tree/master] media: platform: mtk-mdp3: extend GCE event waiting in RDMA and WROT

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

Subject: media: platform: mtk-mdp3: extend GCE event waiting in RDMA and WROT
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:33 2023 +0100

Support for multiple RDMA/WROT waits for GCE events.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mdp_cfg_data.c|  2 ++
 .../media/platform/mediatek/mdp3/mtk-mdp3-comp.c   | 27 +++---
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.h   |  2 ++
 3 files changed, 23 insertions(+), 8 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c 
b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
index 6f77c33074ec..3834efe54e17 100644
--- a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
+++ b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
@@ -56,8 +56,10 @@ static const struct mdp_platform_config mt8183_plat_cfg = {
.rdma_support_10bit = true,
.rdma_rsz1_sram_sharing = true,
.rdma_upsample_repeat_only  = true,
+   .rdma_event_num = 1,
.rsz_disable_dcm_small_sample   = false,
.wrot_filter_constraint = false,
+   .wrot_event_num = 1,
 };
 
 static const u32 mt8183_mutex_idx[MDP_MAX_COMP_COUNT] = {
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
index 93df2e013438..ed6092e1666f 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
@@ -251,14 +251,20 @@ static int config_rdma_subfrm(struct mdp_comp_ctx *ctx,
 
 static int wait_rdma_event(struct mdp_comp_ctx *ctx, struct mdp_cmdq_cmd *cmd)
 {
+   const struct mdp_platform_config *mdp_cfg = __get_plat_cfg(ctx);
struct device *dev = &ctx->comp->mdp_dev->pdev->dev;
phys_addr_t base = ctx->comp->reg_base;
u8 subsys_id = ctx->comp->subsys_id;
 
-   if (ctx->comp->alias_id == 0)
-   MM_REG_WAIT(cmd, ctx->comp->gce_event[MDP_GCE_EVENT_EOF]);
-   else
-   dev_err(dev, "Do not support RDMA1_DONE event\n");
+   if (!mdp_cfg)
+   return -EINVAL;
+
+   if (ctx->comp->alias_id >= mdp_cfg->rdma_event_num) {
+   dev_err(dev, "Invalid RDMA event %d\n", ctx->comp->alias_id);
+   return -EINVAL;
+   }
+
+   MM_REG_WAIT(cmd, ctx->comp->gce_event[MDP_GCE_EVENT_EOF]);
 
/* Disable RDMA */
MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_EN, 0x0, BIT(0));
@@ -553,10 +559,15 @@ static int wait_wrot_event(struct mdp_comp_ctx *ctx, 
struct mdp_cmdq_cmd *cmd)
phys_addr_t base = ctx->comp->reg_base;
u8 subsys_id = ctx->comp->subsys_id;
 
-   if (ctx->comp->alias_id == 0)
-   MM_REG_WAIT(cmd, ctx->comp->gce_event[MDP_GCE_EVENT_EOF]);
-   else
-   dev_err(dev, "Do not support WROT1_DONE event\n");
+   if (!mdp_cfg)
+   return -EINVAL;
+
+   if (ctx->comp->alias_id >= mdp_cfg->wrot_event_num) {
+   dev_err(dev, "Invalid WROT event %d!\n", ctx->comp->alias_id);
+   return -EINVAL;
+   }
+
+   MM_REG_WAIT(cmd, ctx->comp->gce_event[MDP_GCE_EVENT_EOF]);
 
if (mdp_cfg && mdp_cfg->wrot_filter_constraint)
MM_REG_WRITE(cmd, subsys_id, base, VIDO_MAIN_BUF_SIZE, 0x0,
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
index 22d1b17ef2fc..e57c415a1c78 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
@@ -49,8 +49,10 @@ struct mdp_platform_config {
boolrdma_support_10bit;
boolrdma_rsz1_sram_sharing;
boolrdma_upsample_repeat_only;
+   u32 rdma_event_num;
boolrsz_disable_dcm_small_sample;
boolwrot_filter_constraint;
+   u32 wrot_event_num;
 };
 
 /* indicate which mutex is used by each pipepline */


[git:media_tree/master] media: platform: mtk-mdp3: avoid multiple driver registrations

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

Subject: media: platform: mtk-mdp3: avoid multiple driver registrations
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:32 2023 +0100

The amount of MDP3 driver probes is determined by the registered
clocks of MMSYS.
Since MT8195 MDP3 utilizes VPPSYS0 and VPPSYS1, it's necessary to
prevent multiple driver registrations.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c  | 1 +
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 8 
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 1 +
 3 files changed, 10 insertions(+)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c 
b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
index fe92c0474bfa..6f77c33074ec 100644
--- a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
+++ b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
@@ -410,6 +410,7 @@ static const struct mdp_pipe_info mt8183_pipe_info[] = {
 
 const struct mtk_mdp_driver_data mt8183_mdp_driver_data = {
.mdp_plat_id = MT8183,
+   .mdp_con_res = 0x14001000,
.mdp_probe_infra = mt8183_mdp_probe_infra,
.mdp_cfg = &mt8183_plat_cfg,
.mdp_mutex_table_idx = mt8183_mutex_idx,
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
index 4802b20d7f20..6ddb5e075f5d 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
@@ -211,6 +211,7 @@ static int mdp_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct mdp_dev *mdp;
struct platform_device *mm_pdev;
+   struct resource *res;
int ret, i, mutex_id;
 
mdp = kzalloc(sizeof(*mdp), GFP_KERNEL);
@@ -222,6 +223,12 @@ static int mdp_probe(struct platform_device *pdev)
mdp->pdev = pdev;
mdp->mdp_data = of_device_get_match_data(&pdev->dev);
 
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (res->start != mdp->mdp_data->mdp_con_res) {
+   platform_set_drvdata(pdev, mdp);
+   goto success_return;
+   }
+
ret = mdp_mm_subsys_deploy(mdp, MDP_INFRA_MMSYS);
if (ret)
goto err_destroy_device;
@@ -311,6 +318,7 @@ static int mdp_probe(struct platform_device *pdev)
goto err_unregister_device;
}
 
+success_return:
dev_dbg(dev, "mdp-%d registered successfully\n", pdev->id);
return 0;
 
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
index ece6509666fd..22d1b17ef2fc 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
@@ -71,6 +71,7 @@ enum mdp_pipe_id {
 
 struct mtk_mdp_driver_data {
const int mdp_plat_id;
+   const resource_size_t mdp_con_res;
const struct of_device_id *mdp_probe_infra;
const struct mdp_platform_config *mdp_cfg;
const u32 *mdp_mutex_table_idx;


[git:media_tree/master] media: platform: mtk-mdp3: add mt8195 platform configuration

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

Subject: media: platform: mtk-mdp3: add mt8195 platform configuration
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:35 2023 +0100

Add MT8195 MDP3 basic configuration in file "mdp_cfg_data.c"
and corresponding driver data.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mdp_cfg_data.c| 666 +
 drivers/media/platform/mediatek/mdp3/mtk-img-ipi.h |   1 +
 .../media/platform/mediatek/mdp3/mtk-mdp3-cfg.h|   1 +
 .../media/platform/mediatek/mdp3/mtk-mdp3-comp.c   |  36 ++
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.c   |   6 +
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.h   |   6 +
 6 files changed, 716 insertions(+)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c 
b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
index 3834efe54e17..9ee3931d31e3 100644
--- a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
+++ b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
@@ -46,12 +46,91 @@ enum mt8183_mdp_comp_id {
MT8183_MDP_COMP_WROT1,  /* 25 */
 };
 
+enum mt8195_mdp_comp_id {
+   /* MT8195 Comp id */
+   /* ISP */
+   MT8195_MDP_COMP_WPEI = 0,
+   MT8195_MDP_COMP_WPEO,   /* 1 */
+   MT8195_MDP_COMP_WPEI2,  /* 2 */
+   MT8195_MDP_COMP_WPEO2,  /* 3 */
+
+   /* MDP */
+   MT8195_MDP_COMP_CAMIN,  /* 4 */
+   MT8195_MDP_COMP_CAMIN2, /* 5 */
+   MT8195_MDP_COMP_SPLIT,  /* 6 */
+   MT8195_MDP_COMP_SPLIT2, /* 7 */
+   MT8195_MDP_COMP_RDMA0,  /* 8 */
+   MT8195_MDP_COMP_RDMA1,  /* 9 */
+   MT8195_MDP_COMP_RDMA2,  /* 10 */
+   MT8195_MDP_COMP_RDMA3,  /* 11 */
+   MT8195_MDP_COMP_STITCH, /* 12 */
+   MT8195_MDP_COMP_FG0,/* 13 */
+   MT8195_MDP_COMP_FG1,/* 14 */
+   MT8195_MDP_COMP_FG2,/* 15 */
+   MT8195_MDP_COMP_FG3,/* 16 */
+   MT8195_MDP_COMP_TO_SVPP2MOUT,   /* 17 */
+   MT8195_MDP_COMP_TO_SVPP3MOUT,   /* 18 */
+   MT8195_MDP_COMP_TO_WARP0MOUT,   /* 19 */
+   MT8195_MDP_COMP_TO_WARP1MOUT,   /* 20 */
+   MT8195_MDP_COMP_VPP0_SOUT,  /* 21 */
+   MT8195_MDP_COMP_VPP1_SOUT,  /* 22 */
+   MT8195_MDP_COMP_PQ0_SOUT,   /* 23 */
+   MT8195_MDP_COMP_PQ1_SOUT,   /* 24 */
+   MT8195_MDP_COMP_HDR0,   /* 25 */
+   MT8195_MDP_COMP_HDR1,   /* 26 */
+   MT8195_MDP_COMP_HDR2,   /* 27 */
+   MT8195_MDP_COMP_HDR3,   /* 28 */
+   MT8195_MDP_COMP_AAL0,   /* 29 */
+   MT8195_MDP_COMP_AAL1,   /* 30 */
+   MT8195_MDP_COMP_AAL2,   /* 31 */
+   MT8195_MDP_COMP_AAL3,   /* 32 */
+   MT8195_MDP_COMP_RSZ0,   /* 33 */
+   MT8195_MDP_COMP_RSZ1,   /* 34 */
+   MT8195_MDP_COMP_RSZ2,   /* 35 */
+   MT8195_MDP_COMP_RSZ3,   /* 36 */
+   MT8195_MDP_COMP_TDSHP0, /* 37 */
+   MT8195_MDP_COMP_TDSHP1, /* 38 */
+   MT8195_MDP_COMP_TDSHP2, /* 39 */
+   MT8195_MDP_COMP_TDSHP3, /* 40 */
+   MT8195_MDP_COMP_COLOR0, /* 41 */
+   MT8195_MDP_COMP_COLOR1, /* 42 */
+   MT8195_MDP_COMP_COLOR2, /* 43 */
+   MT8195_MDP_COMP_COLOR3, /* 44 */
+   MT8195_MDP_COMP_OVL0,   /* 45 */
+   MT8195_MDP_COMP_OVL1,   /* 46 */
+   MT8195_MDP_COMP_PAD0,   /* 47 */
+   MT8195_MDP_COMP_PAD1,   /* 48 */
+   MT8195_MDP_COMP_PAD2,   /* 49 */
+   MT8195_MDP_COMP_PAD3,   /* 50 */
+   MT8195_MDP_COMP_TCC0,   /* 51 */
+   MT8195_MDP_COMP_TCC1,   /* 52 */
+   MT8195_MDP_COMP_WROT0,  /* 53 */
+   MT8195_MDP_COMP_WROT1,  /* 54 */
+   MT8195_MDP_COMP_WROT2,  /* 55 */
+   MT8195_MDP_COMP_WROT3,  /* 56 */
+   MT8195_MDP_COMP_MERGE2, /* 57 */
+   MT8195_MDP_COMP_MERGE3, /* 58 */
+
+   MT8195_MDP_COMP_VDO0DL0,/* 59 */
+   MT8195_MDP_COMP_VDO1DL0,/* 60 */
+   MT8195_MDP_COMP_VDO0DL1,/* 61 */
+   MT8195_MDP_COMP_VDO1DL1,/* 62 */
+};
+
 static const struct of_device_id mt8183_mdp_probe_infra[MDP_INFRA_MAX] = {
[MDP_INFRA_MMSYS] = { .compatible = "mediatek,mt8183-mmsys" },
[MDP_INFRA_MUTEX] = { .compatible = "mediatek,mt8183-disp-mutex" },
[MDP_INFRA_SCP] = { .compatible = "mediatek,mt8183-scp" }
 };
 
+static const struct of_device_id mt8195_mdp_probe_infra[MDP_INFRA_MAX] = {
+   [MDP_INFRA_MMSYS] = { .compatible = "mediatek,mt8195-vppsys0" },
+   [MDP_INFRA_MMSYS2] = { .compatible = "mediatek,mt8195-vppsys1" },
+   [MDP_INFRA_MUTEX] = { .compatible = "mediatek,mt8195-

[git:media_tree/master] media: platform: mtk-mdp3: introduce more MDP3 components

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

Subject: media: platform: mtk-mdp3: introduce more MDP3 components
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:30 2023 +0100

Add configuration of more components in MT8195 MDP3.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/platform/mediatek/mdp3/mdp_reg_aal.h | 25 +++
 .../media/platform/mediatek/mdp3/mdp_reg_color.h   | 31 
 drivers/media/platform/mediatek/mdp3/mdp_reg_fg.h  | 23 ++
 drivers/media/platform/mediatek/mdp3/mdp_reg_hdr.h | 31 
 .../media/platform/mediatek/mdp3/mdp_reg_merge.h   | 25 +++
 drivers/media/platform/mediatek/mdp3/mdp_reg_ovl.h | 25 +++
 drivers/media/platform/mediatek/mdp3/mdp_reg_pad.h | 21 ++
 .../media/platform/mediatek/mdp3/mdp_reg_rdma.h| 24 ++
 drivers/media/platform/mediatek/mdp3/mdp_reg_rsz.h |  2 +
 .../media/platform/mediatek/mdp3/mdp_reg_tdshp.h   | 34 +
 .../media/platform/mediatek/mdp3/mdp_reg_wrot.h|  8 ++
 .../media/platform/mediatek/mdp3/mtk-mdp3-comp.h   | 85 ++
 12 files changed, 318 insertions(+), 16 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mdp_reg_aal.h 
b/drivers/media/platform/mediatek/mdp3/mdp_reg_aal.h
new file mode 100644
index ..4b9513e54543
--- /dev/null
+++ b/drivers/media/platform/mediatek/mdp3/mdp_reg_aal.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Ping-Hsun Wu 
+ */
+
+#ifndef __MDP_REG_AAL_H__
+#define __MDP_REG_AAL_H__
+
+#define MDP_AAL_EN (0x000)
+#define MDP_AAL_CFG(0x020)
+#define MDP_AAL_SIZE   (0x030)
+#define MDP_AAL_OUTPUT_SIZE(0x034)
+#define MDP_AAL_OUTPUT_OFFSET  (0x038)
+#define MDP_AAL_CFG_MAIN   (0x200)
+
+/* MASK */
+#define MDP_AAL_EN_MASK(0x01)
+#define MDP_AAL_CFG_MASK   (0x70FF00B3)
+#define MDP_AAL_SIZE_MASK  (0x1FFF1FFF)
+#define MDP_AAL_OUTPUT_SIZE_MASK   (0x1FFF1FFF)
+#define MDP_AAL_OUTPUT_OFFSET_MASK (0x0FF00FF)
+#define MDP_AAL_CFG_MAIN_MASK  (0x0FE)
+
+#endif  // __MDP_REG_AAL_H__
diff --git a/drivers/media/platform/mediatek/mdp3/mdp_reg_color.h 
b/drivers/media/platform/mediatek/mdp3/mdp_reg_color.h
new file mode 100644
index ..f72503975b24
--- /dev/null
+++ b/drivers/media/platform/mediatek/mdp3/mdp_reg_color.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Ping-Hsun Wu 
+ */
+
+#ifndef __MDP_REG_COLOR_H__
+#define __MDP_REG_COLOR_H__
+
+#define MDP_COLOR_WIN_X_MAIN   (0x40C)
+#define MDP_COLOR_WIN_Y_MAIN   (0x410)
+#define MDP_COLOR_START(0xC00)
+#define MDP_COLOR_INTEN(0xC04)
+#define MDP_COLOR_OUT_SEL  (0xC0C)
+#define MDP_COLOR_INTERNAL_IP_WIDTH(0xC50)
+#define MDP_COLOR_INTERNAL_IP_HEIGHT   (0xC54)
+#define MDP_COLOR_CM1_EN   (0xC60)
+#define MDP_COLOR_CM2_EN   (0xCA0)
+
+/* MASK */
+#define MDP_COLOR_WIN_X_MAIN_MASK  (0x)
+#define MDP_COLOR_WIN_Y_MAIN_MASK  (0x)
+#define MDP_COLOR_START_MASK   (0x0FF013F)
+#define MDP_COLOR_INTEN_MASK   (0x07)
+#define MDP_COLOR_OUT_SEL_MASK (0x0777)
+#define MDP_COLOR_INTERNAL_IP_WIDTH_MASK   (0x03FFF)
+#define MDP_COLOR_INTERNAL_IP_HEIGHT_MASK  (0x03FFF)
+#define MDP_COLOR_CM1_EN_MASK  (0x03)
+#define MDP_COLOR_CM2_EN_MASK  (0x017)
+
+#endif  // __MDP_REG_COLOR_H__
diff --git a/drivers/media/platform/mediatek/mdp3/mdp_reg_fg.h 
b/drivers/media/platform/mediatek/mdp3/mdp_reg_fg.h
new file mode 100644
index ..d90bcad33a59
--- /dev/null
+++ b/drivers/media/platform/mediatek/mdp3/mdp_reg_fg.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ * Author: Ping-Hsun Wu 
+ */
+
+#ifndef __MDP_REG_FG_H__
+#define __MDP_REG_FG_H__
+
+#define MDP_FG_TRIGGER (0x0)
+#define MDP_FG_FG_CTRL_0   (0x20)
+#define MDP_FG_FG_CK_EN(0x24)
+#define MDP_FG_TILE_INFO_0 (0x418)
+#define MDP_FG_TILE_INFO_1 (0x41c)
+
+/* MASK */
+#define MDP_FG_TRIGGER_MASK(0x0007)
+#define MDP_FG_FG_CTRL_0_MASK  (0x0033)
+#define MDP_FG_FG_CK_EN_MASK   (0x000F)
+#define MDP_FG_TILE_INFO_0_MASK(0x)
+#define MDP_FG_TILE_INFO_1_MASK(0x)
+
+#endif  //__MDP_REG_FG_H__
diff --git a/drivers/media/platform/mediatek/mdp3/mdp_reg_hdr.h 
b/drivers/media/platform/mediatek/mdp3/mdp_reg_hdr.h
new fil

[git:media_tree/master] media: platform: mtk-mdp3: add support second sets of MUTEX

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

Subject: media: platform: mtk-mdp3: add support second sets of MUTEX
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:28 2023 +0100

After setting up the second set of MMSYS (VPPSYS1), it is necessary
to have a corresponding second set of MUTEX (MUTEX2) to assist in
handling SOF/EOF.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c   | 57 +-
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.c   | 51 ++-
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.h   |  4 +-
 3 files changed, 74 insertions(+), 38 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index 6adac857a477..67c8fcc3eda9 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -44,15 +44,21 @@ static bool is_output_disabled(int p_id, const struct 
img_compparam *param, u32
return (count < num) ? (dis_output || dis_tile) : true;
 }
 
+static struct mtk_mutex *__get_mutex(const struct mdp_dev *mdp_dev,
+const struct mdp_pipe_info *p)
+{
+   return mdp_dev->mm_subsys[p->sub_id].mdp_mutex[p->mutex_id];
+}
+
 static int mdp_path_subfrm_require(const struct mdp_path *path,
   struct mdp_cmdq_cmd *cmd,
-  s32 *mutex_id, u32 count)
+  struct mdp_pipe_info *p, u32 count)
 {
const int p_id = path->mdp_dev->mdp_data->mdp_plat_id;
const struct mdp_comp_ctx *ctx;
const struct mtk_mdp_driver_data *data = path->mdp_dev->mdp_data;
struct device *dev = &path->mdp_dev->pdev->dev;
-   struct mtk_mutex **mutex = path->mdp_dev->mdp_mutex;
+   struct mtk_mutex *mutex;
int id, index;
u32 num_comp = 0;
 
@@ -77,7 +83,8 @@ static int mdp_path_subfrm_require(const struct mdp_path 
*path,
dev_err(dev, "Unknown pipeline and no mutex is assigned");
return -EINVAL;
}
-   *mutex_id = data->pipe_info[index].mutex_id;
+   memcpy(p, &data->pipe_info[index], sizeof(struct mdp_pipe_info));
+   mutex = __get_mutex(path->mdp_dev, p);
 
/* Set mutex mod */
for (index = 0; index < num_comp; index++) {
@@ -85,29 +92,28 @@ static int mdp_path_subfrm_require(const struct mdp_path 
*path,
if (is_output_disabled(p_id, ctx->param, count))
continue;
id = ctx->comp->public_id;
-   mtk_mutex_write_mod(mutex[*mutex_id],
-   data->mdp_mutex_table_idx[id], false);
+   mtk_mutex_write_mod(mutex, data->mdp_mutex_table_idx[id], 
false);
+
}
 
-   mtk_mutex_write_sof(mutex[*mutex_id],
-   MUTEX_SOF_IDX_SINGLE_MODE);
+   mtk_mutex_write_sof(mutex, MUTEX_SOF_IDX_SINGLE_MODE);
 
return 0;
 }
 
 static int mdp_path_subfrm_run(const struct mdp_path *path,
   struct mdp_cmdq_cmd *cmd,
-  s32 *mutex_id, u32 count)
+  struct mdp_pipe_info *p, u32 count)
 {
const int p_id = path->mdp_dev->mdp_data->mdp_plat_id;
const struct mdp_comp_ctx *ctx;
struct device *dev = &path->mdp_dev->pdev->dev;
-   struct mtk_mutex **mutex = path->mdp_dev->mdp_mutex;
+   struct mtk_mutex *mutex;
int index;
u32 num_comp = 0;
s32 event;
 
-   if (-1 == *mutex_id) {
+   if (-1 == p->mutex_id) {
dev_err(dev, "Incorrect mutex id");
return -EINVAL;
}
@@ -127,7 +133,8 @@ static int mdp_path_subfrm_run(const struct mdp_path *path,
}
 
/* Enable the mutex */
-   mtk_mutex_enable_by_cmdq(mutex[*mutex_id], (void *)&cmd->pkt);
+   mutex = __get_mutex(path->mdp_dev, p);
+   mtk_mutex_enable_by_cmdq(mutex, (void *)&cmd->pkt);
 
/* Wait SOF events and clear mutex modules (optional) */
for (index = 0; index < num_comp; index++) {
@@ -174,7 +181,7 @@ static int mdp_path_config_subfrm(struct mdp_cmdq_cmd *cmd,
const struct img_mmsys_ctrl *ctrl = NULL;
const struct img_mux *set;
struct mdp_comp_ctx *ctx;
-   s32 mutex_id;
+   struct mdp_pipe_info pipe;
int index, ret;
u32 num_comp = 0;
 
@@ -185,7 +192,7 @@ static int mdp_path_config_subfrm(struct mdp_cmdq_cmd *cmd,
ctrl = CFG_ADDR(MT8183, path->config, ctrls[count]);
 
/* Acquire components */
-   ret = mdp_path_subfrm_require(path, cmd, &mutex_id, count);
+   ret = mdp_path_subfrm_require(path, cmd, &pipe, count);
if (ret)
return 

[git:media_tree/master] media: platform: mtk-mdp3: introduce more pipelines from MT8195

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

Subject: media: platform: mtk-mdp3: introduce more pipelines from MT8195
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:29 2023 +0100

Increasing the number of sets built by MMSYS and MUTEX in MT8195
will enable the creation of more pipelines in MDP3.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c   | 80 ++
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.h   |  7 ++
 2 files changed, 60 insertions(+), 27 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index 67c8fcc3eda9..31930ddbc828 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -50,6 +50,43 @@ static struct mtk_mutex *__get_mutex(const struct mdp_dev 
*mdp_dev,
return mdp_dev->mm_subsys[p->sub_id].mdp_mutex[p->mutex_id];
 }
 
+static enum mdp_pipe_id __get_pipe(const struct mdp_dev *mdp_dev,
+  enum mtk_mdp_comp_id id)
+{
+   enum mdp_pipe_id pipe_id;
+
+   switch (id) {
+   case MDP_COMP_RDMA0:
+   pipe_id = MDP_PIPE_RDMA0;
+   break;
+   case MDP_COMP_ISP_IMGI:
+   pipe_id = MDP_PIPE_IMGI;
+   break;
+   case MDP_COMP_WPEI:
+   pipe_id = MDP_PIPE_WPEI;
+   break;
+   case MDP_COMP_WPEI2:
+   pipe_id = MDP_PIPE_WPEI2;
+   break;
+   case MDP_COMP_RDMA1:
+   pipe_id = MDP_PIPE_RDMA1;
+   break;
+   case MDP_COMP_RDMA2:
+   pipe_id = MDP_PIPE_RDMA2;
+   break;
+   case MDP_COMP_RDMA3:
+   pipe_id = MDP_PIPE_RDMA3;
+   break;
+   default:
+   /* Avoid exceptions when operating MUTEX */
+   pipe_id = MDP_PIPE_RDMA0;
+   dev_err(&mdp_dev->pdev->dev, "Unknown pipeline id %d", id);
+   break;
+   }
+
+   return pipe_id;
+}
+
 static int mdp_path_subfrm_require(const struct mdp_path *path,
   struct mdp_cmdq_cmd *cmd,
   struct mdp_pipe_info *p, u32 count)
@@ -57,7 +94,6 @@ static int mdp_path_subfrm_require(const struct mdp_path 
*path,
const int p_id = path->mdp_dev->mdp_data->mdp_plat_id;
const struct mdp_comp_ctx *ctx;
const struct mtk_mdp_driver_data *data = path->mdp_dev->mdp_data;
-   struct device *dev = &path->mdp_dev->pdev->dev;
struct mtk_mutex *mutex;
int id, index;
u32 num_comp = 0;
@@ -66,23 +102,7 @@ static int mdp_path_subfrm_require(const struct mdp_path 
*path,
num_comp = CFG_GET(MT8183, path->config, num_components);
 
/* Decide which mutex to use based on the current pipeline */
-   switch (path->comps[0].comp->public_id) {
-   case MDP_COMP_RDMA0:
-   index = MDP_PIPE_RDMA0;
-   break;
-   case MDP_COMP_ISP_IMGI:
-   index = MDP_PIPE_IMGI;
-   break;
-   case MDP_COMP_WPEI:
-   index = MDP_PIPE_WPEI;
-   break;
-   case MDP_COMP_WPEI2:
-   index = MDP_PIPE_WPEI2;
-   break;
-   default:
-   dev_err(dev, "Unknown pipeline and no mutex is assigned");
-   return -EINVAL;
-   }
+   index = __get_pipe(path->mdp_dev, path->comps[0].comp->public_id);
memcpy(p, &data->pipe_info[index], sizeof(struct mdp_pipe_info));
mutex = __get_mutex(path->mdp_dev, p);
 
@@ -336,11 +356,13 @@ static void mdp_auto_release_work(struct work_struct 
*work)
struct mdp_cmdq_cmd *cmd;
struct mdp_dev *mdp;
struct mtk_mutex *mutex;
+   enum mdp_pipe_id pipe_id;
 
cmd = container_of(work, struct mdp_cmdq_cmd, auto_release_work);
mdp = cmd->mdp;
 
-   mutex = __get_mutex(mdp, &mdp->mdp_data->pipe_info[MDP_PIPE_RDMA0]);
+   pipe_id = __get_pipe(mdp, cmd->comps[0].public_id);
+   mutex = __get_mutex(mdp, &mdp->mdp_data->pipe_info[pipe_id]);
mtk_mutex_unprepare(mutex);
mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps,
cmd->num_comps);
@@ -361,6 +383,7 @@ static void mdp_handle_cmdq_callback(struct mbox_client 
*cl, void *mssg)
struct cmdq_cb_data *data;
struct mdp_dev *mdp;
struct device *dev;
+   enum mdp_pipe_id pipe_id;
 
if (!mssg) {
pr_info("%s:no callback data\n", __func__);
@@ -388,7 +411,8 @@ static void mdp_handle_cmdq_callback(struct mbox_client 
*cl, void *mssg)
struct mtk_mutex *mutex;
 
dev_err(dev, "%s:queue_work fail!\n", __func__);
-   mutex = __get_

[git:media_tree/master] media: atomisp: Remove unnecessary msleep(10) from atomisp_mrfld_power() error path

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

Subject: media: atomisp: Remove unnecessary msleep(10) from 
atomisp_mrfld_power() error path
Author:  Hans de Goede 
Date:Sat Dec 30 15:37:54 2023 +0100

Remove unnecessary msleep(10) from atomisp_mrfld_power() error-exit path,
the success exit from atomisp_mrfld_power() happens if a test succeeds
inside the do { } while loop above the msleep().

The error-exit path with the removed msleep is only hit it the power-on is
not reflected in the iUNIT ISPSSPM0 status bits after a timeout of 50 ms.
Sleeping an extra 10 ms in the timeout path makes little sense.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 3 ---
 1 file changed, 3 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 7e241f4e9e93..f736e54c7df3 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -587,9 +587,6 @@ static int atomisp_mrfld_power(struct atomisp_device *isp, 
bool enable)
usleep_range(100, 150);
} while (1);
 
-   if (enable)
-   msleep(10);
-
dev_err(isp->dev, "IUNIT power-%s timeout.\n", enable ? "on" : "off");
return -EBUSY;
 }


[git:media_tree/master] media: atomisp: Update TODO

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

Subject: media: atomisp: Update TODO
Author:  Hans de Goede 
Date:Sun Dec 31 11:00:21 2023 +0100

Remove the TODO items for using the main (drivers/media/i2c) ov2680 and
ov5693 drivers and removing the atomisp specific ones, this has been done.

Remove the TODO item for gracefully handling missing firmware the
"media: atomisp: Bind and do power-management without firmware" changes
have fixed this.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/TODO | 10 --
 1 file changed, 10 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/TODO 
b/drivers/staging/media/atomisp/TODO
index d99cc898cd99..bfef7a1d 100644
--- a/drivers/staging/media/atomisp/TODO
+++ b/drivers/staging/media/atomisp/TODO
@@ -29,16 +29,6 @@ TODO
 
 1. Items which MUST be fixed before the driver can be moved out of staging:
 
-* The atomisp ov2680 and ov5693 sensor drivers bind to the same hw-ids as
-  the standard ov2680 and ov5693 drivers under drivers/media/i2c, which
-  conflicts. Drop the atomisp private ov2680 and ov5693 drivers:
-  * Port various ov2680 improvements from atomisp_ov2680.c to regular ov2680.c
-and switch to regular ov2680 driver
-  * Make atomisp work with the regular ov5693 driver and drop atomisp_ov5693
-
-* Fix atomisp causing the whole machine to hang in its probe() error-exit
-  path taken in the firmware missing case
-
 * Remove/disable private IOCTLs
 
 * Remove/disable custom v4l2-ctrls


[git:media_tree/master] media: atomisp: Move power-management [un]init into atomisp_pm_[un]init()

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

Subject: media: atomisp: Move power-management [un]init into 
atomisp_pm_[un]init()
Author:  Hans de Goede 
Date:Fri Dec 29 23:14:20 2023 +0100

Move the power-management setup and cleanup code into
atomisp_pm_[un]init() helper functions.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 69 +---
 1 file changed, 38 insertions(+), 31 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 0c78c1d82659..f44be2d656a8 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1192,6 +1192,41 @@ atomisp_load_firmware(struct atomisp_device *isp)
return fw;
 }
 
+static void atomisp_pm_init(struct atomisp_device *isp)
+{
+   /*
+* The atomisp does not use standard PCI power-management through the
+* PCI config space. Instead this driver directly tells the P-Unit to
+* disable the ISP over the IOSF. The standard PCI subsystem pm_ops will
+* try to access the config space before (resume) / after (suspend) this
+* driver has turned the ISP on / off, resulting in the following 
errors:
+*
+* "Unable to change power state from D0 to D3hot, device inaccessible"
+* "Unable to change power state from D3cold to D0, device inaccessible"
+*
+* To avoid these errors override the pm_domain so that all the PCI
+* subsys suspend / resume handling is skipped.
+*/
+   isp->pm_domain.ops.runtime_suspend = atomisp_power_off;
+   isp->pm_domain.ops.runtime_resume = atomisp_power_on;
+   isp->pm_domain.ops.suspend = atomisp_suspend;
+   isp->pm_domain.ops.resume = atomisp_resume;
+
+   cpu_latency_qos_add_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
+   dev_pm_domain_set(isp->dev, &isp->pm_domain);
+
+   pm_runtime_allow(isp->dev);
+   pm_runtime_put_sync_suspend(isp->dev);
+}
+
+static void atomisp_pm_uninit(struct atomisp_device *isp)
+{
+   pm_runtime_get_sync(isp->dev);
+   pm_runtime_forbid(isp->dev);
+   dev_pm_domain_set(isp->dev, NULL);
+   cpu_latency_qos_remove_request(&isp->pm_qos);
+}
+
 #define ATOM_ISP_PCI_BAR   0
 
 static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*id)
@@ -1438,29 +1473,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
isp->firmware = NULL;
isp->css_env.isp_css_fw.data = NULL;
 
-   /*
-* The atomisp does not use standard PCI power-management through the
-* PCI config space. Instead this driver directly tells the P-Unit to
-* disable the ISP over the IOSF. The standard PCI subsystem pm_ops will
-* try to access the config space before (resume) / after (suspend) this
-* driver has turned the ISP on / off, resulting in the following 
errors:
-*
-* "Unable to change power state from D0 to D3hot, device inaccessible"
-* "Unable to change power state from D3cold to D0, device inaccessible"
-*
-* To avoid these errors override the pm_domain so that all the PCI
-* subsys suspend / resume handling is skipped.
-*/
-   isp->pm_domain.ops.runtime_suspend = atomisp_power_off;
-   isp->pm_domain.ops.runtime_resume = atomisp_power_on;
-   isp->pm_domain.ops.suspend = atomisp_suspend;
-   isp->pm_domain.ops.resume = atomisp_resume;
-
-   cpu_latency_qos_add_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
-   dev_pm_domain_set(&pdev->dev, &isp->pm_domain);
-
-   pm_runtime_allow(&pdev->dev);
-   pm_runtime_put_sync_suspend(&pdev->dev);
+   atomisp_pm_init(isp);
 
err = v4l2_async_nf_register(&isp->notifier);
if (err) {
@@ -1471,10 +1484,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
return 0;
 
 error_unload_firmware:
-   pm_runtime_get_sync(&pdev->dev);
-   pm_runtime_forbid(&pdev->dev);
-   dev_pm_domain_set(&pdev->dev, NULL);
-   cpu_latency_qos_remove_request(&isp->pm_qos);
+   atomisp_pm_uninit(isp);
ia_css_unload_firmware();
 error_free_irq:
devm_free_irq(&pdev->dev, pdev->irq, isp);
@@ -1495,10 +1505,7 @@ static void atomisp_pci_remove(struct pci_dev *pdev)
 {
struct atomisp_device *isp = pci_get_drvdata(pdev);
 
-   pm_runtime_get_sync(&pdev->dev);
-   pm_runtime_forbid(&pdev->dev);
-   dev_pm_domain_set(&pdev->dev, NULL);
-   cpu_latency_qos_remove_request(&isp->pm_qos);
+   atomisp_pm_uninit(isp);
 
/* Undo ia_css_init() from atomisp_power_on() */
atomisp_css_uninit(isp);


[git:media_tree/master] media: atomisp: Replace atomisp_drvfs attr with using driver.dev_groups attr

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

Subject: media: atomisp: Replace atomisp_drvfs attr with using 
driver.dev_groups attr
Author:  Hans de Goede 
Date:Fri Dec 29 22:04:43 2023 +0100

sysfs attributes preferably should not be manually be registered but
instead the driver.groups / driver.dev_groups driver struct members
should be used to have the driver core handle this in a race free
manner.

Using driver.groups would be the most direct replacement for
driver_[add|remove]_file, but some of the attributes actually need access
to the struct atomisp_device (*), so as part of modernizing this part of
the atomisp driver this change also makes the sysfs attribute device
attributes instead of driver attributes.

*) Before this change accessing these attributes without the driver having
bound would result in a NULL pointer deref, this commit fixes this.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_drvfs.c | 144 --
 drivers/staging/media/atomisp/pci/atomisp_drvfs.h |   5 +-
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c  |   9 +-
 3 files changed, 60 insertions(+), 98 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_drvfs.c 
b/drivers/staging/media/atomisp/pci/atomisp_drvfs.c
index 1df534bf54d3..293171da1266 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_drvfs.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_drvfs.c
@@ -27,31 +27,17 @@
 #include "hmm/hmm.h"
 #include "ia_css_debug.h"
 
+#define OPTION_BIN_LISTBIT(0)
+#define OPTION_BIN_RUN BIT(1)
+#define OPTION_VALID   (OPTION_BIN_LIST | OPTION_BIN_RUN)
+
 /*
- * _iunit_debug:
- * dbglvl: iunit css driver trace level
  * dbgopt: iunit debug option:
  *bit 0: binary list
  *bit 1: running binary
  *bit 2: memory statistic
-*/
-struct _iunit_debug {
-   struct device_driver*drv;
-   struct atomisp_device   *isp;
-   unsigned intdbglvl;
-   unsigned intdbgfun;
-   unsigned intdbgopt;
-};
-
-#define OPTION_BIN_LISTBIT(0)
-#define OPTION_BIN_RUN BIT(1)
-#define OPTION_VALID   (OPTION_BIN_LIST \
-   | OPTION_BIN_RUN)
-
-static struct _iunit_debug iunit_debug = {
-   .dbglvl = 0,
-   .dbgopt = OPTION_BIN_LIST,
-};
+ */
+unsigned int dbgopt = OPTION_BIN_LIST;
 
 static inline int iunit_dump_dbgopt(struct atomisp_device *isp,
unsigned int opt)
@@ -88,34 +74,44 @@ opt_err:
return ret;
 }
 
-static ssize_t iunit_dbglvl_show(struct device_driver *drv, char *buf)
+static ssize_t dbglvl_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
 {
-   iunit_debug.dbglvl = dbg_level;
-   return sysfs_emit(buf, "dtrace level:%u\n", iunit_debug.dbglvl);
+   unsigned int dbglvl = ia_css_debug_get_dtrace_level();
+
+   return sysfs_emit(buf, "dtrace level:%u\n", dbglvl);
 }
 
-static ssize_t iunit_dbglvl_store(struct device_driver *drv, const char *buf,
- size_t size)
+static ssize_t dbglvl_store(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t size)
 {
-   if (kstrtouint(buf, 10, &iunit_debug.dbglvl)
-   || iunit_debug.dbglvl < 1
-   || iunit_debug.dbglvl > 9) {
+   unsigned int dbglvl;
+   int ret;
+
+   ret = kstrtouint(buf, 10, &dbglvl);
+   if (ret)
+   return ret;
+
+   if (dbglvl < 1 || dbglvl > 9)
return -ERANGE;
-   }
-   ia_css_debug_set_dtrace_level(iunit_debug.dbglvl);
 
+   ia_css_debug_set_dtrace_level(dbglvl);
return size;
 }
+static DEVICE_ATTR_RW(dbglvl);
 
-static ssize_t iunit_dbgfun_show(struct device_driver *drv, char *buf)
+static ssize_t dbgfun_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
 {
-   iunit_debug.dbgfun = atomisp_get_css_dbgfunc();
-   return sysfs_emit(buf, "dbgfun opt:%u\n", iunit_debug.dbgfun);
+   unsigned int dbgfun = atomisp_get_css_dbgfunc();
+
+   return sysfs_emit(buf, "dbgfun opt:%u\n", dbgfun);
 }
 
-static ssize_t iunit_dbgfun_store(struct device_driver *drv, const char *buf,
- size_t size)
+static ssize_t dbgfun_store(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t size)
 {
+   struct atomisp_device *isp = dev_get_drvdata(dev);
unsigned int opt;
int ret;
 
@@ -123,23 +119,20 @@ static ssize_t iunit_dbgfun_store(struct device_driver 
*drv, const char *buf,
if (ret)
return ret;
 
-   ret = atomisp_set_css_dbgfunc(iunit_debug.isp, opt);
-   if (ret)
-   

[git:media_tree/master] media: platform: mtk-mdp3: add checks for dummy components

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

Subject: media: platform: mtk-mdp3: add checks for dummy components
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:31 2023 +0100

Some components act as bridges only and do not require full configuration.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mdp_cfg_data.c|  8 +++
 .../media/platform/mediatek/mdp3/mtk-mdp3-cfg.h|  1 +
 .../media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c   | 58 +-
 .../media/platform/mediatek/mdp3/mtk-mdp3-comp.c   |  9 +++-
 4 files changed, 74 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c 
b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
index fcc582292b77..fe92c0474bfa 100644
--- a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
+++ b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
@@ -451,3 +451,11 @@ enum mtk_mdp_comp_id mdp_cfg_get_id_public(struct mdp_dev 
*mdp_dev, s32 inner_id
 err_public_id:
return public_id;
 }
+
+bool mdp_cfg_comp_is_dummy(struct mdp_dev *mdp_dev, s32 inner_id)
+{
+   enum mtk_mdp_comp_id id = mdp_cfg_get_id_public(mdp_dev, inner_id);
+   enum mdp_comp_type type = mdp_dev->mdp_data->comp_data[id].match.type;
+
+   return (type == MDP_COMP_TYPE_DUMMY);
+}
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cfg.h 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cfg.h
index dee57cc4a954..dfffc72868e4 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cfg.h
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cfg.h
@@ -16,5 +16,6 @@ enum mtk_mdp_comp_id;
 
 s32 mdp_cfg_get_id_inner(struct mdp_dev *mdp_dev, enum mtk_mdp_comp_id id);
 enum mtk_mdp_comp_id mdp_cfg_get_id_public(struct mdp_dev *mdp_dev, s32 id);
+bool mdp_cfg_comp_is_dummy(struct mdp_dev *mdp_dev, s32 inner_id);
 
 #endif  /* __MTK_MDP3_CFG_H__ */
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c 
b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index 31930ddbc828..a81caf5f472c 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include "mtk-mdp3-cfg.h"
 #include "mtk-mdp3-cmdq.h"
 #include "mtk-mdp3-comp.h"
 #include "mtk-mdp3-core.h"
@@ -108,6 +109,12 @@ static int mdp_path_subfrm_require(const struct mdp_path 
*path,
 
/* Set mutex mod */
for (index = 0; index < num_comp; index++) {
+   s32 inner_id = MDP_COMP_NONE;
+
+   if (CFG_CHECK(MT8183, p_id))
+   inner_id = CFG_GET(MT8183, path->config, 
components[index].type);
+   if (mdp_cfg_comp_is_dummy(path->mdp_dev, inner_id))
+   continue;
ctx = &path->comps[index];
if (is_output_disabled(p_id, ctx->param, count))
continue;
@@ -132,6 +139,7 @@ static int mdp_path_subfrm_run(const struct mdp_path *path,
int index;
u32 num_comp = 0;
s32 event;
+   s32 inner_id = MDP_COMP_NONE;
 
if (-1 == p->mutex_id) {
dev_err(dev, "Incorrect mutex id");
@@ -144,6 +152,10 @@ static int mdp_path_subfrm_run(const struct mdp_path *path,
/* Wait WROT SRAM shared to DISP RDMA */
/* Clear SOF event for each engine */
for (index = 0; index < num_comp; index++) {
+   if (CFG_CHECK(MT8183, p_id))
+   inner_id = CFG_GET(MT8183, path->config, 
components[index].type);
+   if (mdp_cfg_comp_is_dummy(path->mdp_dev, inner_id))
+   continue;
ctx = &path->comps[index];
if (is_output_disabled(p_id, ctx->param, count))
continue;
@@ -158,6 +170,10 @@ static int mdp_path_subfrm_run(const struct mdp_path *path,
 
/* Wait SOF events and clear mutex modules (optional) */
for (index = 0; index < num_comp; index++) {
+   if (CFG_CHECK(MT8183, p_id))
+   inner_id = CFG_GET(MT8183, path->config, 
components[index].type);
+   if (mdp_cfg_comp_is_dummy(path->mdp_dev, inner_id))
+   continue;
ctx = &path->comps[index];
if (is_output_disabled(p_id, ctx->param, count))
continue;
@@ -183,6 +199,12 @@ static int mdp_path_ctx_init(struct mdp_dev *mdp, struct 
mdp_path *path)
return -EINVAL;
 
for (index = 0; index < num_comp; index++) {
+   s32 inner_id = MDP_COMP_NONE;
+
+   if (CFG_CHECK(MT8183, p_id))
+   inner_id = CFG_GET(MT8183, path->config, 
components[index].type);
+   if (mdp_cfg_comp_is_dummy(path->mdp_dev, inner_id))
+   continue;
  

[git:media_tree/master] media: atomisp: Fix probe()/remove() power-management

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

Subject: media: atomisp: Fix probe()/remove() power-management
Author:  Hans de Goede 
Date:Wed Dec 27 23:20:11 2023 +0100

Fix probe()/remove() power-management:

-Currently the driver uses pm_runtime_put_noidle() and relies on
 userspace to open + close the /dev/video# node at least once to
 actually turn the ISP off. Replace the pm_runtime_put_noidle()
 with pm_runtime_put_sync() to make sure that the device is turned
 off without relying on userspace for this.
 This also ensures that atomisp_css_init() is run (by atomisp_power_on())
 if the first userspace process opening /dev/video# wants to do more then
 just query the v4l2-caps.
 As part of this change move the pm setup code in probe() to just before
 calling v4l2_async_nf_register() which registers the /dev/* nodes, so
 that the device is left on for the entirety of the probe() function.

-Remove the turning off of the atomisp from the exit-error path,
 the PCI subsystem and subsequent probe() attempts expect the device
 to be in the on state when probe() fails.
 This also fixes the atomisp driver causing the system to hang / freeze
 when its firmware is missing. This freeze is caused by an unidentified
 bug in the power-off on exit-error code which is now removed.

-Make sure that remove() properly powers on the device by replacing
 pm_runtime_get_noresume() with pm_runtime_get_sync. The PCI subsystem
 and subsequent probe() attempts expect the device to be in the on state
 after unbinding the driver.

-Note this also swaps the order of put()/allow() and forbid()/get()
 so that the sync versions actually work by calling allow() before put()
 and forbid() after get()

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 96 +---
 1 file changed, 36 insertions(+), 60 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 7d99b53107b0..6e8c9add35f9 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1200,7 +1200,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
struct atomisp_device *isp;
unsigned int start;
int err, val;
-   u32 irq;
 
/* Pointer to struct device. */
atomisp_dev = &pdev->dev;
@@ -1334,11 +1333,8 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
 
/* Load isp firmware from user space */
isp->firmware = atomisp_load_firmware(isp);
-   if (!isp->firmware) {
-   err = -ENOENT;
-   dev_dbg(&pdev->dev, "Firmware load failed\n");
-   goto error_power_off;
-   }
+   if (!isp->firmware)
+   return -ENOENT;
 
err = sh_css_check_firmware_version(isp->dev, isp->firmware->data);
if (err) {
@@ -1420,6 +1416,28 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
/* save the iunit context only once after all the values are init'ed. */
atomisp_save_iunit_reg(isp);
 
+   /* Init ISP memory management */
+   hmm_init();
+
+   err = devm_request_threaded_irq(&pdev->dev, pdev->irq,
+   atomisp_isr, atomisp_isr_thread,
+   IRQF_SHARED, "isp_irq", isp);
+   if (err) {
+   dev_err(&pdev->dev, "Failed to request irq (%d)\n", err);
+   goto error_unregister_entities;
+   }
+
+   /* Load firmware into ISP memory */
+   err = atomisp_css_load_firmware(isp);
+   if (err) {
+   dev_err(&pdev->dev, "Failed to init css.\n");
+   goto error_free_irq;
+   }
+   /* Clear FW image from memory */
+   release_firmware(isp->firmware);
+   isp->firmware = NULL;
+   isp->css_env.isp_css_fw.data = NULL;
+
/*
 * The atomisp does not use standard PCI power-management through the
 * PCI config space. Instead this driver directly tells the P-Unit to
@@ -1441,30 +1459,8 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
cpu_latency_qos_add_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
dev_pm_domain_set(&pdev->dev, &isp->pm_domain);
 
-   pm_runtime_put_noidle(&pdev->dev);
pm_runtime_allow(&pdev->dev);
-
-   /* Init ISP memory management */
-   hmm_init();
-
-   err = devm_request_threaded_irq(&pdev->dev, pdev->irq,
-   atomisp_isr, atomisp_isr_thread,
-   IRQF_SHARED, "isp_irq", isp);
-   if (err) {
-   dev_err(&pdev->dev, "Failed to request irq (%d)\n", err);
-   goto error_unregister_entities;
-   }
-
-   /* Load firmware in

[git:media_tree/master] media: atomisp: Group cpu_latency_qos_add_request() call together with other PM calls

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

Subject: media: atomisp: Group cpu_latency_qos_add_request() call together with 
other PM calls
Author:  Hans de Goede 
Date:Wed Dec 27 23:02:40 2023 +0100

Group the cpu_latency_qos_add_request() call in probe() together with
the other PM calls in probe().

This is a preparation patch for futher PM fixes / work.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index f3bd2c03dea5..7d99b53107b0 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1370,8 +1370,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
 
atomisp_msi_irq_init(isp);
 
-   cpu_latency_qos_add_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
-
/*
 * for MRFLD, Software/firmware needs to write a 1 to bit 0 of
 * the register at CSI_RECEIVER_SELECTION_REG to enable SH CSI
@@ -1440,6 +1438,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
isp->pm_domain.ops.suspend = atomisp_suspend;
isp->pm_domain.ops.resume = atomisp_resume;
 
+   cpu_latency_qos_add_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
dev_pm_domain_set(&pdev->dev, &isp->pm_domain);
 
pm_runtime_put_noidle(&pdev->dev);
@@ -1486,11 +1485,11 @@ error_unregister_entities:
pm_runtime_forbid(&pdev->dev);
pm_runtime_get_noresume(&pdev->dev);
dev_pm_domain_set(&pdev->dev, NULL);
+   cpu_latency_qos_remove_request(&isp->pm_qos);
atomisp_unregister_entities(isp);
 error_uninitialize_modules:
atomisp_uninitialize_modules(isp);
 error_irq_uninit:
-   cpu_latency_qos_remove_request(&isp->pm_qos);
atomisp_msi_irq_uninit(isp);
pci_free_irq_vectors(pdev);
 error_release_firmware:


[git:media_tree/master] media: atomisp: Fix probe error-exit path

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

Subject: media: atomisp: Fix probe error-exit path
Author:  Hans de Goede 
Date:Wed Dec 27 21:45:48 2023 +0100

Fix probe error-exit path:
-Add a missing ia_css_unload_firmware() call when v4l2_async_nf_register()
 fails
-Add a missing pm_runtime_forbid() call to undo the pm_runtime_allow() call
-Remove the unnecessary pcim_iounmap_regions() those are devm managed
 so they will get cleaned up automatically on an error exit from probe()
-Rename the labels to avoid having multiple labels pointing to the same
 place in the error-exit path

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 39 
 1 file changed, 19 insertions(+), 20 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 0eea20704e66..336c5a895ecc 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1337,25 +1337,25 @@ static int atomisp_pci_probe(struct pci_dev *pdev, 
const struct pci_device_id *i
if (!isp->firmware) {
err = -ENOENT;
dev_dbg(&pdev->dev, "Firmware load failed\n");
-   goto load_fw_fail;
+   goto error_power_off;
}
 
err = sh_css_check_firmware_version(isp->dev, isp->firmware->data);
if (err) {
dev_dbg(&pdev->dev, "Firmware version check failed\n");
-   goto fw_validation_fail;
+   goto error_release_firmware;
}
 
err = pcim_enable_device(pdev);
if (err) {
dev_err(&pdev->dev, "Failed to enable ISP PCI device (%d)\n", 
err);
-   goto pci_enable_fail;
+   goto error_release_firmware;
}
 
err = pcim_iomap_regions(pdev, BIT(ATOM_ISP_PCI_BAR), pci_name(pdev));
if (err) {
dev_err(&pdev->dev, "Failed to I/O memory remapping (%d)\n", 
err);
-   goto ioremap_fail;
+   goto error_release_firmware;
}
 
isp->base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
@@ -1365,7 +1365,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
if (err < 0) {
dev_err(&pdev->dev, "Failed to enable msi (%d)\n", err);
-   goto enable_msi_fail;
+   goto error_release_firmware;
}
 
atomisp_msi_irq_init(isp);
@@ -1408,13 +1408,13 @@ static int atomisp_pci_probe(struct pci_dev *pdev, 
const struct pci_device_id *i
err = atomisp_initialize_modules(isp);
if (err < 0) {
dev_err(&pdev->dev, "atomisp_initialize_modules (%d)\n", err);
-   goto initialize_modules_fail;
+   goto error_irq_uninit;
}
 
err = atomisp_register_entities(isp);
if (err < 0) {
dev_err(&pdev->dev, "atomisp_register_entities failed (%d)\n", 
err);
-   goto register_entities_fail;
+   goto error_uninitialize_modules;
}
 
INIT_WORK(&isp->assert_recovery_work, atomisp_assert_recovery_work);
@@ -1453,14 +1453,14 @@ static int atomisp_pci_probe(struct pci_dev *pdev, 
const struct pci_device_id *i
IRQF_SHARED, "isp_irq", isp);
if (err) {
dev_err(&pdev->dev, "Failed to request irq (%d)\n", err);
-   goto request_irq_fail;
+   goto error_unregister_entities;
}
 
/* Load firmware into ISP memory */
err = atomisp_css_load_firmware(isp);
if (err) {
dev_err(&pdev->dev, "Failed to init css.\n");
-   goto css_init_fail;
+   goto error_free_irq;
}
/* Clear FW image from memory */
release_firmware(isp->firmware);
@@ -1470,33 +1470,32 @@ static int atomisp_pci_probe(struct pci_dev *pdev, 
const struct pci_device_id *i
err = v4l2_async_nf_register(&isp->notifier);
if (err) {
dev_err(isp->dev, "failed to register async notifier : %d\n", 
err);
-   goto css_init_fail;
+   goto error_unload_firmware;
}
 
atomisp_drvfs_init(isp);
 
return 0;
 
-css_init_fail:
+error_unload_firmware:
+   ia_css_unload_firmware();
+error_free_irq:
devm_free_irq(&pdev->dev, pdev->irq, isp);
-request_irq_fail:
+error_unregister_entities:
hmm_cleanup();
+   pm_runtime_forbid(&pdev->dev);
pm_runtime_get_noresume(&pdev->dev);
dev_pm_domain_set(&pdev->dev, NULL);
atomisp_unregister_entities(isp);
-register_entities_fail:
+error_uninitialize_modules:
atomisp_uninitialize_modules(isp);
-initialize_modules_fail:
+error_irq_uninit:
cpu_

[git:media_tree/master] media: atomisp: Call pcim_enable_device() and pcim_iomap_regions() later

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

Subject: media: atomisp: Call pcim_enable_device() and pcim_iomap_regions() 
later
Author:  Hans de Goede 
Date:Sun Nov 12 21:29:28 2023 +0100

ATM the atomisp firmware is not available in linux-firmware,
so most users will not have it installed.

Move pcim_enable_device() and pcim_iomap_regions() down in
atomisp_pci_probe() so that they are never called when the firmware
is not there.

This is a preparation patch for making the atomisp driver handle
missing firmware better.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 45 +++-
 1 file changed, 20 insertions(+), 25 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 176b39906d10..0eea20704e66 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1209,33 +1209,16 @@ static int atomisp_pci_probe(struct pci_dev *pdev, 
const struct pci_device_id *i
if (!pdata)
dev_warn(&pdev->dev, "no platform data available\n");
 
-   err = pcim_enable_device(pdev);
-   if (err) {
-   dev_err(&pdev->dev, "Failed to enable CI ISP device (%d)\n", 
err);
-   return err;
-   }
-
start = pci_resource_start(pdev, ATOM_ISP_PCI_BAR);
dev_dbg(&pdev->dev, "start: 0x%x\n", start);
 
-   err = pcim_iomap_regions(pdev, BIT(ATOM_ISP_PCI_BAR), pci_name(pdev));
-   if (err) {
-   dev_err(&pdev->dev, "Failed to I/O memory remapping (%d)\n", 
err);
-   goto ioremap_fail;
-   }
-
isp = devm_kzalloc(&pdev->dev, sizeof(*isp), GFP_KERNEL);
-   if (!isp) {
-   err = -ENOMEM;
-   goto atomisp_dev_alloc_fail;
-   }
+   if (!isp)
+   return -ENOMEM;
 
isp->dev = &pdev->dev;
-   isp->base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
isp->saved_regs.ispmmadr = start;
 
-   dev_dbg(&pdev->dev, "atomisp mmio base: %p\n", isp->base);
-
mutex_init(&isp->mutex);
spin_lock_init(&isp->lock);
 
@@ -1337,8 +1320,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
break;
default:
dev_err(&pdev->dev, "un-supported IUNIT device\n");
-   err = -ENODEV;
-   goto atomisp_dev_alloc_fail;
+   return -ENODEV;
}
 
if (pdev->revision <= ATOMISP_PCI_REV_BYT_A0_MAX) {
@@ -1364,6 +1346,20 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
goto fw_validation_fail;
}
 
+   err = pcim_enable_device(pdev);
+   if (err) {
+   dev_err(&pdev->dev, "Failed to enable ISP PCI device (%d)\n", 
err);
+   goto pci_enable_fail;
+   }
+
+   err = pcim_iomap_regions(pdev, BIT(ATOM_ISP_PCI_BAR), pci_name(pdev));
+   if (err) {
+   dev_err(&pdev->dev, "Failed to I/O memory remapping (%d)\n", 
err);
+   goto ioremap_fail;
+   }
+
+   isp->base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
+
pci_set_master(pdev);
 
err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
@@ -1495,6 +1491,9 @@ initialize_modules_fail:
atomisp_msi_irq_uninit(isp);
pci_free_irq_vectors(pdev);
 enable_msi_fail:
+   pcim_iounmap_regions(pdev, BIT(ATOM_ISP_PCI_BAR));
+ioremap_fail:
+pci_enable_fail:
 fw_validation_fail:
release_firmware(isp->firmware);
 load_fw_fail:
@@ -1519,10 +1518,6 @@ load_fw_fail:
if (IS_ENABLED(CONFIG_PM) && atomisp_mrfld_power(isp, false))
dev_err(&pdev->dev, "Failed to switch off ISP\n");
 
-atomisp_dev_alloc_fail:
-   pcim_iounmap_regions(pdev, BIT(ATOM_ISP_PCI_BAR));
-
-ioremap_fail:
return err;
 }
 


[git:media_tree/master] media: platform: mtk-mdp3: add support second sets of MMSYS

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

Subject: media: platform: mtk-mdp3: add support second sets of MMSYS
Author:  Moudy Ho 
Date:Wed Dec 20 11:18:27 2023 +0100

The MT8195 chipset features two MMSYS subsets: VPPSYS0 and VPPSYS1.
These subsets coordinate and control the clock, power, and
register settings required for the components of MDP3.

Signed-off-by: Moudy Ho 
Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Sebastian Fricke 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/platform/mediatek/mdp3/mdp_cfg_data.c| 44 
 .../media/platform/mediatek/mdp3/mtk-mdp3-comp.h   |  1 +
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.c   | 61 ++
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.h   | 18 ++-
 4 files changed, 92 insertions(+), 32 deletions(-)

---

diff --git a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c 
b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
index 502eeae0bfdc..fcc582292b77 100644
--- a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
+++ b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
@@ -73,75 +73,75 @@ static const u32 mt8183_mutex_idx[MDP_MAX_COMP_COUNT] = {
 
 static const struct mdp_comp_data mt8183_mdp_comp_data[MDP_MAX_COMP_COUNT] = {
[MDP_COMP_WPEI] = {
-   {MDP_COMP_TYPE_WPEI, 0, MT8183_MDP_COMP_WPEI},
+   {MDP_COMP_TYPE_WPEI, 0, MT8183_MDP_COMP_WPEI, MDP_MM_SUBSYS_0},
{0, 0, 0}
},
[MDP_COMP_WPEO] = {
-   {MDP_COMP_TYPE_EXTO, 2, MT8183_MDP_COMP_WPEO},
+   {MDP_COMP_TYPE_EXTO, 2, MT8183_MDP_COMP_WPEO, MDP_MM_SUBSYS_0},
{0, 0, 0}
},
[MDP_COMP_WPEI2] = {
-   {MDP_COMP_TYPE_WPEI, 1, MT8183_MDP_COMP_WPEI2},
+   {MDP_COMP_TYPE_WPEI, 1, MT8183_MDP_COMP_WPEI2, MDP_MM_SUBSYS_0},
{0, 0, 0}
},
[MDP_COMP_WPEO2] = {
-   {MDP_COMP_TYPE_EXTO, 3, MT8183_MDP_COMP_WPEO2},
+   {MDP_COMP_TYPE_EXTO, 3, MT8183_MDP_COMP_WPEO2, MDP_MM_SUBSYS_0},
{0, 0, 0}
},
[MDP_COMP_ISP_IMGI] = {
-   {MDP_COMP_TYPE_IMGI, 0, MT8183_MDP_COMP_ISP_IMGI},
+   {MDP_COMP_TYPE_IMGI, 0, MT8183_MDP_COMP_ISP_IMGI, 
MDP_MM_SUBSYS_0},
{0, 0, 4}
},
[MDP_COMP_ISP_IMGO] = {
-   {MDP_COMP_TYPE_EXTO, 0, MT8183_MDP_COMP_ISP_IMGO},
+   {MDP_COMP_TYPE_EXTO, 0, MT8183_MDP_COMP_ISP_IMGO, 
MDP_MM_SUBSYS_0},
{0, 0, 4}
},
[MDP_COMP_ISP_IMG2O] = {
-   {MDP_COMP_TYPE_EXTO, 1, MT8183_MDP_COMP_ISP_IMG2O},
+   {MDP_COMP_TYPE_EXTO, 1, MT8183_MDP_COMP_ISP_IMG2O, 
MDP_MM_SUBSYS_0},
{0, 0, 0}
},
[MDP_COMP_CAMIN] = {
-   {MDP_COMP_TYPE_DL_PATH, 0, MT8183_MDP_COMP_CAMIN},
+   {MDP_COMP_TYPE_DL_PATH, 0, MT8183_MDP_COMP_CAMIN, 
MDP_MM_SUBSYS_0},
{2, 2, 1}
},
[MDP_COMP_CAMIN2] = {
-   {MDP_COMP_TYPE_DL_PATH, 1, MT8183_MDP_COMP_CAMIN2},
+   {MDP_COMP_TYPE_DL_PATH, 1, MT8183_MDP_COMP_CAMIN2, 
MDP_MM_SUBSYS_0},
{2, 4, 1}
},
[MDP_COMP_RDMA0] = {
-   {MDP_COMP_TYPE_RDMA, 0, MT8183_MDP_COMP_RDMA0},
+   {MDP_COMP_TYPE_RDMA, 0, MT8183_MDP_COMP_RDMA0, MDP_MM_SUBSYS_0},
{2, 0, 0}
},
[MDP_COMP_CCORR0] = {
-   {MDP_COMP_TYPE_CCORR, 0, MT8183_MDP_COMP_CCORR0},
+   {MDP_COMP_TYPE_CCORR, 0, MT8183_MDP_COMP_CCORR0, 
MDP_MM_SUBSYS_0},
{1, 0, 0}
},
[MDP_COMP_RSZ0] = {
-   {MDP_COMP_TYPE_RSZ, 0, MT8183_MDP_COMP_RSZ0},
+   {MDP_COMP_TYPE_RSZ, 0, MT8183_MDP_COMP_RSZ0, MDP_MM_SUBSYS_0},
{1, 0, 0}
},
[MDP_COMP_RSZ1] = {
-   {MDP_COMP_TYPE_RSZ, 1, MT8183_MDP_COMP_RSZ1},
+   {MDP_COMP_TYPE_RSZ, 1, MT8183_MDP_COMP_RSZ1, MDP_MM_SUBSYS_0},
{1, 0, 0}
},
[MDP_COMP_TDSHP0] = {
-   {MDP_COMP_TYPE_TDSHP, 0, MT8183_MDP_COMP_TDSHP0},
+   {MDP_COMP_TYPE_TDSHP, 0, MT8183_MDP_COMP_TDSHP0, 
MDP_MM_SUBSYS_0},
{0, 0, 0}
},
[MDP_COMP_PATH0_SOUT] = {
-   {MDP_COMP_TYPE_PATH, 0, MT8183_MDP_COMP_PATH0_SOUT},
+   {MDP_COMP_TYPE_PATH, 0, MT8183_MDP_COMP_PATH0_SOUT, 
MDP_MM_SUBSYS_0},
{0, 0, 0}
},
[MDP_COMP_PATH1_SOUT] = {
-   {MDP_COMP_TYPE_PATH, 1, MT8183_MDP_COMP_PATH1_SOUT},
+   {MDP_COMP_TYPE_PATH, 1, MT8183_MDP_COMP_PATH1_SOUT, 
MDP_MM_SUBSYS_0},
{0, 0, 0}
},
[MDP_COMP_WROT0] = {
-   {MDP_COMP_TYPE_WROT, 0, MT8183_MDP_COMP_WROT0},
+   {MDP_COMP_TYPE_WROT, 0, MT8183_MDP_COMP_WROT0, MDP_MM_SUBSYS_0},
{1, 0, 0}
},
[MDP_COMP_

[git:media_tree/master] media: atomisp: Remove remaining deferred firmware loading code

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

Subject: media: atomisp: Remove remaining deferred firmware loading code
Author:  Hans de Goede 
Date:Fri Nov 10 17:48:48 2023 +0100

There is a bunch of dead code left from the deferred firmware loading
support which was removed in commit 8972ed6ea7a0 ("media: atomisp: Remove
deferred firmware loading support").

Remove this dead code:
- Remove the skip_fwload module parameter
- Remove the now always NULL fw argument from ia_css_init()
- Remove the fw_explicitly_loaded boolean from sh_css.c
  (this was always true now)
- Adjust some function kernel-doc comments to match

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/atomisp/pci/atomisp_compat_css20.c   |  2 +-
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c   |  9 --
 drivers/staging/media/atomisp/pci/ia_css_control.h | 29 ++-
 .../staging/media/atomisp/pci/ia_css_firmware.h|  6 ++--
 drivers/staging/media/atomisp/pci/sh_css.c | 33 ++
 5 files changed, 14 insertions(+), 65 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
index 02f06294bbfe..6fe8b0b7467a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
@@ -757,7 +757,7 @@ int atomisp_css_init(struct atomisp_device *isp)
return ret;
 
/* Init ISP */
-   err = ia_css_init(isp->dev, &isp->css_env.isp_css_env, NULL,
+   err = ia_css_init(isp->dev, &isp->css_env.isp_css_env,
  (uint32_t)mmu_base_addr, IA_CSS_IRQ_TYPE_PULSE);
if (err) {
dev_err(isp->dev, "css init failed --- bad firmware?\n");
diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 547e1444ad97..206fdaee5952 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -55,10 +55,6 @@
 /* G-Min addition: pull this in from intel_mid_pm.h */
 #define CSTATE_EXIT_LATENCY_C1  1
 
-static uint skip_fwload;
-module_param(skip_fwload, uint, 0644);
-MODULE_PARM_DESC(skip_fwload, "Skip atomisp firmware load");
-
 /* cross componnet debug message flag */
 int dbg_level;
 module_param(dbg_level, int, 0644);
@@ -1161,9 +1157,6 @@ atomisp_load_firmware(struct atomisp_device *isp)
int rc;
char *fw_path = NULL;
 
-   if (skip_fwload)
-   return NULL;
-
if (firmware_name[0] != '\0') {
fw_path = firmware_name;
} else {
@@ -1591,8 +1584,6 @@ static void atomisp_pci_remove(struct pci_dev *pdev)
 
atomisp_msi_irq_uninit(isp);
atomisp_unregister_entities(isp);
-
-   release_firmware(isp->firmware);
 }
 
 static const struct pci_device_id atomisp_pci_tbl[] = {
diff --git a/drivers/staging/media/atomisp/pci/ia_css_control.h 
b/drivers/staging/media/atomisp/pci/ia_css_control.h
index 88f031a63ba2..6a473459b346 100644
--- a/drivers/staging/media/atomisp/pci/ia_css_control.h
+++ b/drivers/staging/media/atomisp/pci/ia_css_control.h
@@ -30,39 +30,28 @@
  * environment in which the CSS code runs. This is
  * used for host side memory access and message
  * printing. May not be NULL.
- * @param[in]  fw  Firmware package containing the firmware for all
- * predefined ISP binaries.
- * if fw is NULL the firmware must be loaded before
- * through a call of ia_css_load_firmware
  * @param[in]  l1_base Base index (isp2400)
  *  of the L1 page table. This is a physical
  *  address or index.
  * @param[in]  irq_typeThe type of interrupt to be used (edge or level)
- * @return Returns -EINVAL in case of any
+ * @return Returns -EINVAL in case of any
  * errors and 0 otherwise.
  *
  * This function initializes the API which includes allocating and initializing
- * internal data structures. This also interprets the firmware package. All
- * contents of this firmware package are copied into local data structures, so
- * the fw pointer could be freed after this function completes.
+ * internal data structures.
+ * ia_css_load_firmware() must be called to load the firmware before calling
+ * this function.
  */
 int ia_css_init(struct device   *dev,
-   const struct ia_css_env *env,
-   const struct ia_css_fw  *fw,
-   u32 l1_base,
-   enum ia_css_irq_typeirq_type);
+   const struc

[git:media_tree/master] media: atomisp: Remove s_routing subdev call

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

Subject: media: atomisp: Remove s_routing subdev call
Author:  Hans de Goede 
Date:Thu Dec 28 21:28:07 2023 +0100

sensor drivers do not implement the s_routing subdev call, so there is
no use in calling it.

Also the 3 0 arguments are not the arguments which a successful
s_routing call is supposed to take.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 8 
 1 file changed, 8 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c 
b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
index 5b2d88c02d36..bb8e5e883b50 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
@@ -666,14 +666,6 @@ static int atomisp_s_input(struct file *file, void *fh, 
unsigned int input)
return ret;
}
 
-   /* select operating sensor */
-   ret = v4l2_subdev_call(isp->inputs[input].camera, video, s_routing,
-  0, 0, 0);
-   if (ret && (ret != -ENOIOCTLCMD)) {
-   dev_err(isp->dev, "Failed to select sensor\n");
-   return ret;
-   }
-
if (!IS_ISP2401) {
motor = isp->inputs[input].motor;
} else {


[git:media_tree/master] media: atomisp: Drop is_valid_device() function

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

Subject: media: atomisp: Drop is_valid_device() function
Author:  Hans de Goede 
Date:Tue Dec 26 16:32:10 2023 +0100

Now that a single build supports both the ISP 2400 and the ISP 2401
this function is no longer necessary. The main probe() already
contains a similar switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK)
checking for a known device_id.

Move the revision check into the main probe() and drop
the is_valid_device() function.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 50 +++-
 1 file changed, 5 insertions(+), 45 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 206fdaee5952..176b39906d10 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1192,48 +1192,6 @@ atomisp_load_firmware(struct atomisp_device *isp)
return fw;
 }
 
-/*
- * Check for flags the driver was compiled with against the PCI
- * device. Always returns true on other than ISP 2400.
- */
-static bool is_valid_device(struct pci_dev *pdev, const struct pci_device_id 
*id)
-{
-   const char *name;
-   const char *product;
-
-   product = dmi_get_system_info(DMI_PRODUCT_NAME);
-
-   switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
-   case ATOMISP_PCI_DEVICE_SOC_MRFLD:
-   name = "Merrifield";
-   break;
-   case ATOMISP_PCI_DEVICE_SOC_BYT:
-   name = "Baytrail";
-   break;
-   case ATOMISP_PCI_DEVICE_SOC_ANN:
-   name = "Anniedale";
-   break;
-   case ATOMISP_PCI_DEVICE_SOC_CHT:
-   name = "Cherrytrail";
-   break;
-   default:
-   dev_err(&pdev->dev, "%s: unknown device ID %x04:%x04\n",
-   product, id->vendor, id->device);
-   return false;
-   }
-
-   if (pdev->revision <= ATOMISP_PCI_REV_BYT_A0_MAX) {
-   dev_err(&pdev->dev, "%s revision %d is not unsupported\n",
-   name, pdev->revision);
-   return false;
-   }
-
-   dev_info(&pdev->dev, "Detected %s version %d (ISP240%c) on %s\n",
-name, pdev->revision, IS_ISP2401 ? '1' : '0', product);
-
-   return true;
-}
-
 #define ATOM_ISP_PCI_BAR   0
 
 static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id 
*id)
@@ -1244,9 +1202,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
int err, val;
u32 irq;
 
-   if (!is_valid_device(pdev, id))
-   return -ENODEV;
-
/* Pointer to struct device. */
atomisp_dev = &pdev->dev;
 
@@ -1386,6 +1341,11 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
goto atomisp_dev_alloc_fail;
}
 
+   if (pdev->revision <= ATOMISP_PCI_REV_BYT_A0_MAX) {
+   dev_err(&pdev->dev, "revision %d is not unsupported\n", 
pdev->revision);
+   return -ENODEV;
+   }
+
dev_info(&pdev->dev, "ISP HPLL frequency base = %d MHz\n", 
isp->hpll_freq);
 
isp->max_isr_latency = ATOMISP_MAX_ISR_LATENCY;


[git:media_tree/master] media: atomisp: Bind and do power-management without firmware

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

Subject: media: atomisp: Bind and do power-management without firmware
Author:  Hans de Goede 
Date:Sat Dec 30 15:31:41 2023 +0100

The ISP needs to be turned off in a special manner for the SoC
to be able to reach S0i3 during suspend.

When the firmware is missing still bind to the PCI device and
run in pm-only mode which takes care of turning the ISP off
(including turning it off again if the firmware has turned it
on during resume).

In this new pm-only mode the atomisp driver works exactly the same
as the non-staging, pm-only drivers/platform/x86/intel/atomisp2/pm.c
driver.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 .../staging/media/atomisp/pci/atomisp_internal.h   |  1 +
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c   | 32 --
 2 files changed, 25 insertions(+), 8 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h 
b/drivers/staging/media/atomisp/pci/atomisp_internal.h
index d5b077e602ca..bba9bc64d447 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_internal.h
+++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h
@@ -192,6 +192,7 @@ struct atomisp_device {
struct dev_pm_domain pm_domain;
struct pm_qos_request pm_qos;
s32 max_isr_latency;
+   bool pm_only;
 
struct atomisp_mipi_csi2_device csi2_port[ATOMISP_CAMERA_NR_PORTS];
struct atomisp_tpg_device tpg;
diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index f44be2d656a8..7e241f4e9e93 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -548,7 +548,7 @@ static int atomisp_mrfld_power(struct atomisp_device *isp, 
bool enable)
dev_dbg(isp->dev, "IUNIT power-%s.\n", enable ? "on" : "off");
 
/* WA for P-Unit, if DVFS enabled, ISP timeout observed */
-   if (IS_CHT && enable) {
+   if (IS_CHT && enable && !isp->pm_only) {
punit_ddr_dvfs_enable(false);
msleep(20);
}
@@ -558,7 +558,7 @@ static int atomisp_mrfld_power(struct atomisp_device *isp, 
bool enable)
val, MRFLD_ISPSSPM0_ISPSSC_MASK);
 
/* WA:Enable DVFS */
-   if (IS_CHT && !enable)
+   if (IS_CHT && !enable && !isp->pm_only)
punit_ddr_dvfs_enable(true);
 
/*
@@ -601,11 +601,15 @@ int atomisp_power_off(struct device *dev)
int ret;
u32 reg;
 
-   atomisp_css_uninit(isp);
+   if (isp->pm_only) {
+   pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, 0);
+   } else {
+   atomisp_css_uninit(isp);
 
-   ret = atomisp_mrfld_pre_power_down(isp);
-   if (ret)
-   return ret;
+   ret = atomisp_mrfld_pre_power_down(isp);
+   if (ret)
+   return ret;
+   }
 
/*
 * MRFLD IUNIT DPHY is located in an always-power-on island
@@ -634,6 +638,9 @@ int atomisp_power_on(struct device *dev)
pci_restore_state(to_pci_dev(dev));
cpu_latency_qos_update_request(&isp->pm_qos, isp->max_isr_latency);
 
+   if (isp->pm_only)
+   return 0;
+
/*restore register values for iUnit and iUnitPHY registers*/
if (isp->saved_regs.pcicmdsts)
atomisp_restore_iunit_reg(isp);
@@ -1252,6 +1259,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
 
isp->dev = &pdev->dev;
isp->saved_regs.ispmmadr = start;
+   isp->asd.isp = isp;
 
mutex_init(&isp->mutex);
spin_lock_init(&isp->lock);
@@ -1368,8 +1376,13 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *i
 
/* Load isp firmware from user space */
isp->firmware = atomisp_load_firmware(isp);
-   if (!isp->firmware)
-   return -ENOENT;
+   if (!isp->firmware) {
+   /* No firmware continue in pm-only mode for S0i3 support */
+   dev_info(&pdev->dev, "Continuing in power-management only 
mode\n");
+   isp->pm_only = true;
+   atomisp_pm_init(isp);
+   return 0;
+   }
 
err = sh_css_check_firmware_version(isp->dev, isp->firmware->data);
if (err) {
@@ -1507,6 +1520,9 @@ static void atomisp_pci_remove(struct pci_dev *pdev)
 
atomisp_pm_uninit(isp);
 
+   if (isp->pm_only)
+   return;
+
/* Undo ia_css_init() from atomisp_power_on() */
atomisp_css_uninit(isp);
ia_css_unload_firmware();


[git:media_tree/master] media: atomisp: Fix spelling mistake in binary.c

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

Subject: media: atomisp: Fix spelling mistake in binary.c
Author:  Dipendra Khadka 
Date:Sat Dec 23 10:15:21 2023 +0100

codespell reported following spelling mistake
in runtime/binary/src as below:

'''
./runtime/binary/src/binary.c:537: spcification ==> specification
'''
This patch fixes thisspelling mistake.

Link: https://lore.kernel.org/r/20231223091521.85467-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c 
b/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
index 0f3729e55e14..130662f8e768 100644
--- a/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
+++ b/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
@@ -534,7 +534,7 @@ ia_css_binary_uninit(void) {
 static int
 binary_grid_deci_factor_log2(int width, int height)
 {
-   /* 3A/Shading decimation factor spcification (at August 2008)
+   /* 3A/Shading decimation factor specification (at August 2008)
 * --
 * [Image Width (BQ)] [Decimation Factor (BQ)] [Resulting grid cells]
 * 1280 ?c 32   40 ?c


[git:media_tree/master] media: atomisp: Fix spelling mistake in ia_css_acc_types.h

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

Subject: media: atomisp: Fix spelling mistake in ia_css_acc_types.h
Author:  Dipendra Khadka 
Date:Sat Dec 23 15:11:57 2023 +0100

codespell reported spelling mistakes in
ia_css_acc_types.h as below:

'''
ia_css_acc_types.h:87: cummulative ==> cumulative
ia_css_acc_types.h:411: descibes ==> describes
'''

This patch fixes these spelling mistakes.
Word "cummulative" is changed to "accumulation"
and "descibes" to "describes".

Link: https://lore.kernel.org/r/20231223141157.95501-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Reviewed-by: Randy Dunlap 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/ia_css_acc_types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/ia_css_acc_types.h 
b/drivers/staging/media/atomisp/pci/ia_css_acc_types.h
index d6e52b4971d6..f6838a8fc9d5 100644
--- a/drivers/staging/media/atomisp/pci/ia_css_acc_types.h
+++ b/drivers/staging/media/atomisp/pci/ia_css_acc_types.h
@@ -84,7 +84,7 @@ struct ia_css_blob_info {
memory_offsets;  /** offset wrt hdr in bytes */
u32 prog_name_offset;  /** offset wrt hdr in bytes */
u32 size;   /** Size of blob */
-   u32 padding_size;   /** total cummulative of bytes added due to 
section alignment */
+   u32 padding_size;   /** total accumulation of bytes added due to 
section alignment */
u32 icache_source;  /** Position of icache in blob */
u32 icache_size;/** Size of icache section */
u32 icache_padding;/** bytes added due to icache section alignment */
@@ -408,7 +408,7 @@ struct ia_css_acc_sp {
 };
 
 /* Acceleration firmware descriptor.
-  * This descriptor descibes either SP code (stand-alone), or
+  * This descriptor describes either SP code (stand-alone), or
   * ISP code (a separate pipeline stage).
   */
 struct ia_css_acc_fw_hdr {


[git:media_tree/master] media: atomisp: Fix atomisp_pci_remove()

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

Subject: media: atomisp: Fix atomisp_pci_remove()
Author:  Hans de Goede 
Date:Wed Dec 27 22:47:45 2023 +0100

Fix atomisp_pci_remove():
-Remove uninformative "Removing atomisp driver" log message
-Add missing devm_free_irq(), atomisp_uninitialize_modules() and
 pci_free_irq_vectors() calls
-Move atomisp_msi_irq_uninit() down so that the remove() order is
 an exact mirror of the probe() order

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 336c5a895ecc..f3bd2c03dea5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1524,11 +1524,10 @@ static void atomisp_pci_remove(struct pci_dev *pdev)
 {
struct atomisp_device *isp = pci_get_drvdata(pdev);
 
-   dev_info(&pdev->dev, "Removing atomisp driver\n");
-
atomisp_drvfs_exit();
 
ia_css_unload_firmware();
+   devm_free_irq(&pdev->dev, pdev->irq, isp);
hmm_cleanup();
 
pm_runtime_forbid(&pdev->dev);
@@ -1536,8 +1535,10 @@ static void atomisp_pci_remove(struct pci_dev *pdev)
dev_pm_domain_set(&pdev->dev, NULL);
cpu_latency_qos_remove_request(&isp->pm_qos);
 
-   atomisp_msi_irq_uninit(isp);
atomisp_unregister_entities(isp);
+   atomisp_uninitialize_modules(isp);
+   atomisp_msi_irq_uninit(isp);
+   pci_free_irq_vectors(pdev);
 }
 
 static const struct pci_device_id atomisp_pci_tbl[] = {


[git:media_tree/master] media: atomisp: Fix spelling mistakes in rmgr_vbuf.c

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

Subject: media: atomisp: Fix spelling mistakes in rmgr_vbuf.c
Author:  Dipendra Khadka 
Date:Sat Dec 23 08:22:45 2023 +0100

codespell reported following spelling mistake
in rmgr_vbuf.cas below:

'''
./runtime/rmgr/src/rmgr_vbuf.c:201: succes ==> success
./runtime/rmgr/src/rmgr_vbuf.c:211: succes ==> success
./runtime/rmgr/src/rmgr_vbuf.c:215: succes ==> success
'''
This patch fixes these spelling mistakes.
It is good to use variable name that gives
proper meaning and spelling error free.

Link: https://lore.kernel.org/r/20231223072245.81630-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c 
b/drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c
index 2e07dab8bf51..1f24db77fe38 100644
--- a/drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c
+++ b/drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c
@@ -198,7 +198,7 @@ void rmgr_push_handle(struct ia_css_rmgr_vbuf_pool *pool,
  struct ia_css_rmgr_vbuf_handle **handle)
 {
u32 i;
-   bool succes = false;
+   bool success = false;
 
assert(pool);
assert(pool->recycle);
@@ -208,11 +208,11 @@ void rmgr_push_handle(struct ia_css_rmgr_vbuf_pool *pool,
if (!pool->handles[i]) {
ia_css_rmgr_refcount_retain_vbuf(handle);
pool->handles[i] = *handle;
-   succes = true;
+   success = true;
break;
}
}
-   assert(succes);
+   assert(success);
 }
 
 /*


[git:media_tree/master] media: atomisp: Fix spelling mistakes in queue.c

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

Subject: media: atomisp: Fix spelling mistakes in queue.c
Author:  Dipendra Khadka 
Date:Sat Dec 23 08:11:57 2023 +0100

codespell reported following spelling mistake
in queue.c as below:

'''
./runtime/queue/src/queue.c:126: uncessary ==> unnecessary
./runtime/queue/src/queue.c:183: uncessary ==> unnecessary
'''
This patch fixes these spelling mistakes.

Link: https://lore.kernel.org/r/20231223071157.81082-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c 
b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c
index c4d4062206a2..0e430388b331 100644
--- a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c
+++ b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c
@@ -123,7 +123,7 @@ int ia_css_queue_enqueue(ia_css_queue_t *qhandle, uint32_t 
item)
 
/* c. Store the queue object */
/* Set only fields requiring update with
-* valid value. Avoids uncessary calls
+* valid value. Avoids unnecessary calls
 * to load/store functions
 */
ignore_desc_flags = QUEUE_IGNORE_SIZE_START_STEP_FLAGS;
@@ -180,7 +180,7 @@ int ia_css_queue_dequeue(ia_css_queue_t *qhandle, uint32_t 
*item)
 
/* c. Store the queue object */
/* Set only fields requiring update with
-* valid value. Avoids uncessary calls
+* valid value. Avoids unnecessary calls
 * to load/store functions
 */
ignore_desc_flags = QUEUE_IGNORE_SIZE_END_STEP_FLAGS;


[git:media_tree/master] media: atomisp: Fix spelling mistakes in sh_css_mipi.c

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

Subject: media: atomisp: Fix spelling mistakes in sh_css_mipi.c
Author:  Dipendra Khadka 
Date:Sat Dec 23 07:41:52 2023 +0100

codespell reported following spelling mistake
in sh_css_mipi.c as below:

'''
./sh_css_mipi.c:177: separatelly ==> separately
./sh_css_mipi.c:540: ofset ==> offset, of set
'''
This patch fixes these spelling mistakes by changing
"separatelly" to "separately" and "ofset" to "offset".

Link: https://lore.kernel.org/r/20231223064152.79712-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/sh_css_mipi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c 
b/drivers/staging/media/atomisp/pci/sh_css_mipi.c
index b7c1e164ee24..6e11fd771938 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c
@@ -174,7 +174,7 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,
mem_words = ((embedded_data_size_words + 7) >> 3) +
mem_words_for_first_line +
(((height + 1) >> 1) - 1) * mem_words_per_odd_line +
-   /* ceil (height/2) - 1 (first line is calculated separatelly) */
+   /* ceil (height/2) - 1 (first line is calculated separately) */
(height  >> 1) * mem_words_per_even_line + /* floor(height/2) */
mem_words_for_EOF;
 
@@ -537,7 +537,7 @@ send_mipi_frames(struct ia_css_pipe *pipe)
 
/* Hand-over the SP-internal mipi buffers */
for (i = 0; i < my_css.num_mipi_frames[port]; i++) {
-   /* Need to include the ofset for port. */
+   /* Need to include the offset for port. */
sh_css_update_host2sp_mipi_frame(port * 
NUM_MIPI_FRAMES_PER_STREAM + i,
 my_css.mipi_frames[port][i]);
sh_css_update_host2sp_mipi_metadata(port * 
NUM_MIPI_FRAMES_PER_STREAM + i,


[git:media_tree/master] media: atomisp: Fix spelling mistakes in ia_css_hdr_types.h

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

Subject: media: atomisp: Fix spelling mistakes in ia_css_hdr_types.h
Author:  Dipendra Khadka 
Date:Sat Dec 23 09:31:57 2023 +0100

codespell reported following spelling mistake
in ia_css_hdr_types.h below:

'''
./isp/kernels/hdr/ia_css_hdr_types.h:60: paramterers ==> parameters
./isp/kernels/hdr/ia_css_hdr_types.h:62: Currenly ==> Currently
'''
This patch fixes these spelling mistakes.

Link: https://lore.kernel.org/r/20231223083157.84090-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/isp/kernels/hdr/ia_css_hdr_types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git 
a/drivers/staging/media/atomisp/pci/isp/kernels/hdr/ia_css_hdr_types.h 
b/drivers/staging/media/atomisp/pci/isp/kernels/hdr/ia_css_hdr_types.h
index 175c301ee96a..ecc98686f5cf 100644
--- a/drivers/staging/media/atomisp/pci/isp/kernels/hdr/ia_css_hdr_types.h
+++ b/drivers/staging/media/atomisp/pci/isp/kernels/hdr/ia_css_hdr_types.h
@@ -57,9 +57,9 @@ struct ia_css_hdr_exclusion_params {
 };
 
 /**
- * \brief HDR public paramterers.
+ * \brief HDR public parameters.
  * \details Struct with all parameters for HDR that can be seet from
- * the CSS API. Currenly, only test parameters are defined.
+ * the CSS API. Currently, only test parameters are defined.
  */
 struct ia_css_hdr_config {
struct ia_css_hdr_irradiance_params irradiance; /** HDR irradiance 
parameters */


[git:media_tree/master] media: atomisp: Fix spelling mistakes in ia_css_macc_table.host.c

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

Subject: media: atomisp: Fix spelling mistakes in ia_css_macc_table.host.c
Author:  Dipendra Khadka 
Date:Sat Dec 23 09:13:54 2023 +0100

codespell reported following spelling mistake
in ia_css_macc_table.host.c below:

'''
./isp/kernels/macc/macc_1.0/ia_css_macc_table.host.c:22: matix ==> matrix
./isp/kernels/macc/macc_1.0/ia_css_macc_table.host.c:39: matix ==> matrix
'''
This patch fixes these spelling mistakes.

Link: https://lore.kernel.org/r/20231223081354.83318-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 .../atomisp/pci/isp/kernels/macc/macc_1.0/ia_css_macc_table.host.c| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git 
a/drivers/staging/media/atomisp/pci/isp/kernels/macc/macc_1.0/ia_css_macc_table.host.c
 
b/drivers/staging/media/atomisp/pci/isp/kernels/macc/macc_1.0/ia_css_macc_table.host.c
index 946b074e8288..d25bf59273ba 100644
--- 
a/drivers/staging/media/atomisp/pci/isp/kernels/macc/macc_1.0/ia_css_macc_table.host.c
+++ 
b/drivers/staging/media/atomisp/pci/isp/kernels/macc/macc_1.0/ia_css_macc_table.host.c
@@ -19,7 +19,7 @@
 
 /* Multi-Axes Color Correction table for ISP1.
  * 64values = 2x2matrix for 16area, [s2.13]
- * ineffective: 16 of "identity 2x2 matix" {8192,0,0,8192}
+ * ineffective: 16 of "identity 2x2 matrix" {8192,0,0,8192}
  */
 const struct ia_css_macc_table default_macc_table = {
{
@@ -36,7 +36,7 @@ const struct ia_css_macc_table default_macc_table = {
 
 /* Multi-Axes Color Correction table for ISP2.
  * 64values = 2x2matrix for 16area, [s1.12]
- * ineffective: 16 of "identity 2x2 matix" {4096,0,0,4096}
+ * ineffective: 16 of "identity 2x2 matrix" {4096,0,0,4096}
  */
 const struct ia_css_macc_table default_macc2_table = {
{


[git:media_tree/master] media: atomisp: Fix spelling mistake in ia_css_circbuf.h

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

Subject: media: atomisp: Fix spelling mistake in ia_css_circbuf.h
Author:  Dipendra Khadka 
Date:Sat Dec 23 07:16:47 2023 +0100

codespell reported following spelling mistake
in ia_css_circbuf.h as below:

'''
./base/circbuf/interface/ia_css_circbuf.h:76: poistion ==> position
'''
This patch fixes this spelling mistake.

Link: https://lore.kernel.org/r/20231223061647.78669-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Acked-by: Randy Dunlap 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 .../staging/media/atomisp/pci/base/circbuf/interface/ia_css_circbuf.h   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

diff --git 
a/drivers/staging/media/atomisp/pci/base/circbuf/interface/ia_css_circbuf.h 
b/drivers/staging/media/atomisp/pci/base/circbuf/interface/ia_css_circbuf.h
index 0579deac5535..e9846951f4ed 100644
--- a/drivers/staging/media/atomisp/pci/base/circbuf/interface/ia_css_circbuf.h
+++ b/drivers/staging/media/atomisp/pci/base/circbuf/interface/ia_css_circbuf.h
@@ -73,7 +73,7 @@ uint32_t ia_css_circbuf_pop(
 
 /**
  * @brief Extract a value out of the circular buffer.
- * Get a value at an arbitrary poistion in the circular
+ * Get a value at an arbitrary position in the circular
  * buffer. The user should call "ia_css_circbuf_is_empty()"
  * to avoid accessing to an empty buffer.
  *


[git:media_tree/master] media: atomisp: Fix spelling mistakes in circbuf.c

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

Subject: media: atomisp: Fix spelling mistakes in circbuf.c
Author:  Dipendra Khadka 
Date:Sat Dec 23 07:04:22 2023 +0100

codespell reported following spelling mistakes
in circbuf.c as below:

'''
./circbuf.c:27: whehter ==> whether
./circbuf.c:132: offest ==> offset
'''
This patch fixes these spelling mistakes.

Link: https://lore.kernel.org/r/20231223060422.77789-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Acked-by: Randy Dunlap 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/base/circbuf/src/circbuf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/base/circbuf/src/circbuf.c 
b/drivers/staging/media/atomisp/pci/base/circbuf/src/circbuf.c
index 06f039236abc..198c9f6e6191 100644
--- a/drivers/staging/media/atomisp/pci/base/circbuf/src/circbuf.c
+++ b/drivers/staging/media/atomisp/pci/base/circbuf/src/circbuf.c
@@ -24,7 +24,7 @@
  **/
 /*
  * @brief Read the oldest element from the circular buffer.
- * Read the oldest element WITHOUT checking whehter the
+ * Read the oldest element WITHOUT checking whether the
  * circular buffer is empty or not. The oldest element is
  * also removed out from the circular buffer.
  *
@@ -129,7 +129,7 @@ uint32_t ia_css_circbuf_extract(ia_css_circbuf_t *cb, int 
offset)
u32 src_pos;
u32 dest_pos;
 
-   /* get the maximum offest */
+   /* get the maximum offset */
max_offset = ia_css_circbuf_get_offset(cb, cb->desc->start, 
cb->desc->end);
max_offset--;
 


[git:media_tree/master] media: atomisp: Fix repeated "of" in isp2400_input_system_public.h

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

Subject: media: atomisp: Fix repeated "of" in isp2400_input_system_public.h
Author:  Dipendra Khadka 
Date:Fri Dec 22 20:40:35 2023 +0100

The script checkpatch.pl reported repeated
word 'of' in isp2400_input_system_public.h
as below:

'''
WARNING: Possible repeated word: 'of'
/*! Read from a control register PORT[port_ID] of of RECEIVER[ID]
'''

This patch removes one 'of'.

Link: https://lore.kernel.org/r/20231222194036.1984-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/staging/media/atomisp/pci/isp2400_input_system_public.h 
b/drivers/staging/media/atomisp/pci/isp2400_input_system_public.h
index 447c7c5c55a1..523c948923f3 100644
--- a/drivers/staging/media/atomisp/pci/isp2400_input_system_public.h
+++ b/drivers/staging/media/atomisp/pci/isp2400_input_system_public.h
@@ -163,7 +163,7 @@ STORAGE_CLASS_INPUT_SYSTEM_H void receiver_port_reg_store(
 const hrt_address  reg,
 const hrt_data value);
 
-/*! Read from a control register PORT[port_ID] of of RECEIVER[ID]
+/*! Read from a control register PORT[port_ID] of RECEIVER[ID]
 
  \paramID[in]  RECEIVER identifier
  \paramport_ID[in] mipi PORT identifier


[git:media_tree/master] media: atomisp: Remove redundant assignments to variables

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

Subject: media: atomisp: Remove redundant assignments to variables
Author:  Colin Ian King 
Date:Tue Dec 19 15:39:29 2023 +0100

There are several variables that are being initialized with values
that are never read, the assignment are redundant and can be removed.
Cleans up cppcheck unreadVariable warnings.

Link: https://lore.kernel.org/r/20231219143929.367929-1-colin.i.k...@gmail.com

Signed-off-by: Colin Ian King 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 .../media/atomisp/pci/base/circbuf/src/circbuf.c   |  2 +-
 .../media/atomisp/pci/runtime/pipeline/src/pipeline.c  |  2 +-
 .../media/atomisp/pci/runtime/queue/src/queue.c| 18 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/base/circbuf/src/circbuf.c 
b/drivers/staging/media/atomisp/pci/base/circbuf/src/circbuf.c
index d9f7c143794d..06f039236abc 100644
--- a/drivers/staging/media/atomisp/pci/base/circbuf/src/circbuf.c
+++ b/drivers/staging/media/atomisp/pci/base/circbuf/src/circbuf.c
@@ -207,7 +207,7 @@ bool ia_css_circbuf_increase_size(
 {
u8 curr_size;
u8 curr_end;
-   unsigned int i = 0;
+   unsigned int i;
 
if (!cb || sz_delta == 0)
return false;
diff --git a/drivers/staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c 
b/drivers/staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c
index 3d8741e7d5ca..9d2b5f9cbb14 100644
--- a/drivers/staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c
+++ b/drivers/staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c
@@ -693,7 +693,7 @@ static void pipeline_init_defaults(
 static void ia_css_pipeline_set_zoom_stage(struct ia_css_pipeline *pipeline)
 {
struct ia_css_pipeline_stage *stage = NULL;
-   int err = 0;
+   int err;
 
assert(pipeline);
if (pipeline->pipe_id == IA_CSS_PIPE_ID_PREVIEW) {
diff --git a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c 
b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c
index 2f1c2df59f71..c4d4062206a2 100644
--- a/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c
+++ b/drivers/staging/media/atomisp/pci/runtime/queue/src/queue.c
@@ -81,7 +81,7 @@ int ia_css_queue_uninit(ia_css_queue_t *qhandle)
 
 int ia_css_queue_enqueue(ia_css_queue_t *qhandle, uint32_t item)
 {
-   int error = 0;
+   int error;
 
if (!qhandle)
return -EINVAL;
@@ -138,7 +138,7 @@ int ia_css_queue_enqueue(ia_css_queue_t *qhandle, uint32_t 
item)
 
 int ia_css_queue_dequeue(ia_css_queue_t *qhandle, uint32_t *item)
 {
-   int error = 0;
+   int error;
 
if (!qhandle || NULL == item)
return -EINVAL;
@@ -193,7 +193,7 @@ int ia_css_queue_dequeue(ia_css_queue_t *qhandle, uint32_t 
*item)
 
 int ia_css_queue_is_full(ia_css_queue_t *qhandle, bool *is_full)
 {
-   int error = 0;
+   int error;
 
if ((!qhandle) || (!is_full))
return -EINVAL;
@@ -225,7 +225,7 @@ int ia_css_queue_is_full(ia_css_queue_t *qhandle, bool 
*is_full)
 
 int ia_css_queue_get_free_space(ia_css_queue_t *qhandle, uint32_t *size)
 {
-   int error = 0;
+   int error;
 
if ((!qhandle) || (!size))
return -EINVAL;
@@ -257,7 +257,7 @@ int ia_css_queue_get_free_space(ia_css_queue_t *qhandle, 
uint32_t *size)
 
 int ia_css_queue_get_used_space(ia_css_queue_t *qhandle, uint32_t *size)
 {
-   int error = 0;
+   int error;
 
if ((!qhandle) || (!size))
return -EINVAL;
@@ -289,8 +289,8 @@ int ia_css_queue_get_used_space(ia_css_queue_t *qhandle, 
uint32_t *size)
 
 int ia_css_queue_peek(ia_css_queue_t *qhandle, u32 offset, uint32_t *element)
 {
-   u32 num_elems = 0;
-   int error = 0;
+   u32 num_elems;
+   int error;
 
if ((!qhandle) || (!element))
return -EINVAL;
@@ -338,7 +338,7 @@ int ia_css_queue_peek(ia_css_queue_t *qhandle, u32 offset, 
uint32_t *element)
 
 int ia_css_queue_is_empty(ia_css_queue_t *qhandle, bool *is_empty)
 {
-   int error = 0;
+   int error;
 
if ((!qhandle) || (!is_empty))
return -EINVAL;
@@ -370,7 +370,7 @@ int ia_css_queue_is_empty(ia_css_queue_t *qhandle, bool 
*is_empty)
 
 int ia_css_queue_get_size(ia_css_queue_t *qhandle, uint32_t *size)
 {
-   int error = 0;
+   int error;
 
if ((!qhandle) || (!size))
return -EINVAL;


[git:media_tree/master] media: atomisp: Fix a spelling mistake in sh_css_defs.h

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

Subject: media: atomisp: Fix a spelling mistake in sh_css_defs.h
Author:  Dipendra Khadka 
Date:Mon Dec 18 16:32:00 2023 +0100

The script checkpatch.pl reported a spelling error
in sh_css_defs.h as below:

'''
WARNING: 'upto' may be misspelled - perhaps 'up to'?
/* The FPGA system (vec_nelems == 16) only supports upto 5MP */

'''

This patch corrects a spelling error,
changing "upto" to "up to".

Link: https://lore.kernel.org/r/20231218153200.450148-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/staging/media/atomisp/pci/sh_css_defs.h 
b/drivers/staging/media/atomisp/pci/sh_css_defs.h
index 7eb10b226f0a..2afde974e75d 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_defs.h
+++ b/drivers/staging/media/atomisp/pci/sh_css_defs.h
@@ -131,7 +131,7 @@ RGB[0,8191],coef[-8192,8191] -> RGB[0,8191]
  * invalid rows/columns that result from filter initialization are skipped. */
 #define SH_CSS_MIN_DVS_ENVELOPE   12U
 
-/* The FPGA system (vec_nelems == 16) only supports upto 5MP */
+/* The FPGA system (vec_nelems == 16) only supports up to 5MP */
 #define SH_CSS_MAX_SENSOR_WIDTH   4608
 #define SH_CSS_MAX_SENSOR_HEIGHT  3450
 


[git:media_tree/master] media: atomisp: Fix spelling mistake in isp2400_input_system_global.h

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

Subject: media: atomisp: Fix spelling mistake in isp2400_input_system_global.h
Author:  Dipendra Khadka 
Date:Fri Dec 22 21:15:03 2023 +0100

The script checkpatch.pl reported a spelling error
in isp2400_input_system_global.h as below:

'''
WARNING: 'upto' may be misspelled - perhaps 'up to'?
//MIPI allows upto 4 channels.
  
'''

This patch corrects a spelling error,
changing "upto" to "up to".

Link: https://lore.kernel.org/r/2023101503.2337-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

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

---

diff --git a/drivers/staging/media/atomisp/pci/isp2400_input_system_global.h 
b/drivers/staging/media/atomisp/pci/isp2400_input_system_global.h
index 61f23814e2fd..3ff61faf0621 100644
--- a/drivers/staging/media/atomisp/pci/isp2400_input_system_global.h
+++ b/drivers/staging/media/atomisp/pci/isp2400_input_system_global.h
@@ -19,7 +19,7 @@
 #defineN_CSI_PORTS (3)
 //AM: Use previous define for this.
 
-//MIPI allows upto 4 channels.
+//MIPI allows up to 4 channels.
 #defineN_CHANNELS  (4)
 // 12KB = 256bit x 384 words
 #defineIB_CAPACITY_IN_WORDS (384)


[git:media_tree/master] media: atomisp: Adjust for v4l2_subdev_state handling changes in 6.8

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

Subject: media: atomisp: Adjust for v4l2_subdev_state handling changes in 6.8
Author:  Hans de Goede 
Date:Thu Dec 28 22:43:25 2023 +0100

The atomisp driver emulates a standard v4l2 device, which also works
for non media-controller aware applications.

Part of this requires making try_fmt calls on the sensor when
a normal v4l2 app is making try_fmt calls on the /dev/video# mode.

With the recent v4l2_subdev_state handling changes in 6.8 this no longer
works, fixing this requires 2 changes:

1. The atomisp code was using its own internal v4l2_subdev_pad_config
   for this. Replace the internal v4l2_subdev_pad_config with allocating
   a full v4l2_subdev_state for storing the full try_fmt state.

2. The paths actually setting the fmt or crop selection now need to be
   passed the v4l2_subdev's active state, so that sensor drivers which
   are using the v4l2_subdev's active state to store their state keep
   working.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_cmd.c| 58 -
 .../staging/media/atomisp/pci/atomisp_internal.h   |  4 +-
 drivers/staging/media/atomisp/pci/atomisp_ioctl.c  | 52 +++
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c   | 59 --
 4 files changed, 111 insertions(+), 62 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index f44e6412f4e3..d0db2efe0045 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -3723,12 +3723,10 @@ apply_min_padding:
 
 static int atomisp_set_crop(struct atomisp_device *isp,
const struct v4l2_mbus_framefmt *format,
+   struct v4l2_subdev_state *sd_state,
int which)
 {
struct atomisp_input_subdev *input = &isp->inputs[isp->asd.input_curr];
-   struct v4l2_subdev_state pad_state = {
-   .pads = &input->pad_cfg,
-   };
struct v4l2_subdev_selection sel = {
.which = which,
.target = V4L2_SEL_TGT_CROP,
@@ -3754,7 +3752,7 @@ static int atomisp_set_crop(struct atomisp_device *isp,
sel.r.left = ((input->native_rect.width - sel.r.width) / 2) & ~1;
sel.r.top = ((input->native_rect.height - sel.r.height) / 2) & ~1;
 
-   ret = v4l2_subdev_call(input->camera, pad, set_selection, &pad_state, 
&sel);
+   ret = v4l2_subdev_call(input->camera, pad, set_selection, sd_state, 
&sel);
if (ret)
dev_err(isp->dev, "Error setting crop to %ux%u @%ux%u: %d\n",
sel.r.width, sel.r.height, sel.r.left, sel.r.top, ret);
@@ -3770,9 +3768,6 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct 
v4l2_pix_format *f,
const struct atomisp_format_bridge *fmt, *snr_fmt;
struct atomisp_sub_device *asd = &isp->asd;
struct atomisp_input_subdev *input = &isp->inputs[asd->input_curr];
-   struct v4l2_subdev_state pad_state = {
-   .pads = &input->pad_cfg,
-   };
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
@@ -3809,11 +3804,16 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct 
v4l2_pix_format *f,
dev_dbg(isp->dev, "try_mbus_fmt: asking for %ux%u\n",
format.format.width, format.format.height);
 
-   ret = atomisp_set_crop(isp, &format.format, V4L2_SUBDEV_FORMAT_TRY);
-   if (ret)
-   return ret;
+   v4l2_subdev_lock_state(input->try_sd_state);
+
+   ret = atomisp_set_crop(isp, &format.format, input->try_sd_state,
+  V4L2_SUBDEV_FORMAT_TRY);
+   if (ret == 0)
+   ret = v4l2_subdev_call(input->camera, pad, set_fmt,
+  input->try_sd_state, &format);
+
+   v4l2_subdev_unlock_state(input->try_sd_state);
 
-   ret = v4l2_subdev_call(input->camera, pad, set_fmt, &pad_state, 
&format);
if (ret)
return ret;
 
@@ -4238,9 +4238,7 @@ static int atomisp_set_fmt_to_snr(struct video_device 
*vdev, const struct v4l2_p
struct atomisp_device *isp = asd->isp;
struct atomisp_input_subdev *input = &isp->inputs[asd->input_curr];
const struct atomisp_format_bridge *format;
-   struct v4l2_subdev_state pad_state = {
-   .pads = &input->pad_cfg,
-   };
+   struct v4l2_subdev_state *act_sd_state;
struct v4l2_subdev_format vformat = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
@@ -4268,12 +4266,18 @@ static int atomisp_set_fmt_to_snr(struct video_device 
*vdev, const struct v4l2_p
 
/* Disable dvs if resolution can't be supported by sensor */
if (asd->params.video_dis_en && asd->run_mode->val 

[git:media_tree/master] media: atomisp: Removed duplicate comment and fixed comment format

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

Subject: media: atomisp: Removed duplicate comment and fixed comment format
Author:  Jonathan Bergh 
Date:Sat Oct 14 10:35:45 2023 +0200

Fixed the following issues:
 * Removed a duplicate comment
 * Fixed up minor comment format issue

Link: https://lore.kernel.org/r/20231014083545.173238-1-bergh.jonat...@gmail.com

Signed-off-by: Jonathan Bergh 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/i2c/gc2235.h | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/i2c/gc2235.h 
b/drivers/staging/media/atomisp/i2c/gc2235.h
index 55ea422291ba..ade28950db73 100644
--- a/drivers/staging/media/atomisp/i2c/gc2235.h
+++ b/drivers/staging/media/atomisp/i2c/gc2235.h
@@ -74,9 +74,6 @@
 #define GC2235_COARSE_INTG_TIME_MIN 1
 #define GC2235_COARSE_INTG_TIME_MAX_MARGIN 6
 
-/*
- * GC2235 System control registers
- */
 /*
  * GC2235 System control registers
  */
@@ -167,7 +164,7 @@ enum gc2235_tok_type {
GC2235_TOK_MASK = 0xfff0
 };
 
-/**
+/*
  * struct gc2235_reg - MI sensor  register format
  * @type: type of the register
  * @reg: 8-bit offset to register


[git:media_tree/master] media: atomisp: Refactor sensor crop + fmt setting

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

Subject: media: atomisp: Refactor sensor crop + fmt setting
Author:  Hans de Goede 
Date:Fri Dec 29 16:41:55 2023 +0100

There are 3 code-paths all of 3 which need to do:

1. Get try or active state
2. lock state
3. Call atomisp_set_crop()
4. Call v4l2_subdev_call(input->camera, pad, set_fmt, state, fmt)
5. unlock state

Change atomisp_set_crop into atomisp_set_crop_and_fmt() which does all of
this and change the 3 code-paths which need this to use the new
atomisp_set_crop_and_fmt() function.

Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/atomisp_cmd.c | 141 ++--
 1 file changed, 58 insertions(+), 83 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index d0db2efe0045..8593ba90605f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -3721,22 +3721,34 @@ apply_min_padding:
*padding_h = max_t(u32, *padding_h, min_pad_h);
 }
 
-static int atomisp_set_crop(struct atomisp_device *isp,
-   const struct v4l2_mbus_framefmt *format,
-   struct v4l2_subdev_state *sd_state,
-   int which)
+static int atomisp_set_crop_and_fmt(struct atomisp_device *isp,
+   struct v4l2_mbus_framefmt *ffmt,
+   int which)
 {
struct atomisp_input_subdev *input = &isp->inputs[isp->asd.input_curr];
struct v4l2_subdev_selection sel = {
.which = which,
.target = V4L2_SEL_TGT_CROP,
-   .r.width = format->width,
-   .r.height = format->height,
+   .r.width = ffmt->width,
+   .r.height = ffmt->height,
};
-   int ret;
+   struct v4l2_subdev_format format = {
+   .which = which,
+   .format = *ffmt,
+   };
+   struct v4l2_subdev_state *sd_state;
+   int ret = 0;
+
+   if (!input->camera)
+   return -EINVAL;
+
+   sd_state = (which == V4L2_SUBDEV_FORMAT_TRY) ? input->try_sd_state :
+  
input->camera->active_state;
+   if (sd_state)
+   v4l2_subdev_lock_state(sd_state);
 
if (!input->crop_support)
-   return 0;
+   goto set_fmt;
 
/* Cropping is done before binning, when binning double the crop rect */
if (input->binning_support && sel.r.width <= (input->native_rect.width 
/ 2) &&
@@ -3757,6 +3769,14 @@ static int atomisp_set_crop(struct atomisp_device *isp,
dev_err(isp->dev, "Error setting crop to %ux%u @%ux%u: %d\n",
sel.r.width, sel.r.height, sel.r.left, sel.r.top, ret);
 
+set_fmt:
+   if (ret == 0)
+   ret = v4l2_subdev_call(input->camera, pad, set_fmt, sd_state, 
&format);
+
+   if (sd_state)
+   v4l2_subdev_unlock_state(sd_state);
+
+   *ffmt = format.format;
return ret;
 }
 
@@ -3767,16 +3787,10 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct 
v4l2_pix_format *f,
 {
const struct atomisp_format_bridge *fmt, *snr_fmt;
struct atomisp_sub_device *asd = &isp->asd;
-   struct atomisp_input_subdev *input = &isp->inputs[asd->input_curr];
-   struct v4l2_subdev_format format = {
-   .which = V4L2_SUBDEV_FORMAT_TRY,
-   };
+   struct v4l2_mbus_framefmt ffmt = { };
u32 padding_w, padding_h;
int ret;
 
-   if (!input->camera)
-   return -EINVAL;
-
fmt = atomisp_get_format_bridge(f->pixelformat);
/* Currently, raw formats are broken!!! */
if (!fmt || fmt->sh_fmt == IA_CSS_FRAME_FORMAT_RAW) {
@@ -3797,38 +3811,27 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct 
v4l2_pix_format *f,
 * the set_fmt call, like atomisp_set_fmt_to_snr() does.
 */
atomisp_get_padding(isp, f->width, f->height, &padding_w, &padding_h);
-   v4l2_fill_mbus_format(&format.format, f, fmt->mbus_code);
-   format.format.width += padding_w;
-   format.format.height += padding_h;
-
-   dev_dbg(isp->dev, "try_mbus_fmt: asking for %ux%u\n",
-   format.format.width, format.format.height);
-
-   v4l2_subdev_lock_state(input->try_sd_state);
+   v4l2_fill_mbus_format(&ffmt, f, fmt->mbus_code);
+   ffmt.width += padding_w;
+   ffmt.height += padding_h;
 
-   ret = atomisp_set_crop(isp, &format.format, input->try_sd_state,
-  V4L2_SUBDEV_FORMAT_TRY);
-   if (ret == 0)
-   ret = v4l2_subdev_call(input->camera, pad, set_fmt,
-  input->try_sd_state, &format);
-
-   v4l2_subdev_unlock_state(input->try_sd_state

[git:media_tree/master] media: atomisp: Fix spelling mistakes in ia_css_irq.h

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

Subject: media: atomisp: Fix spelling mistakes in ia_css_irq.h
Author:  Dipendra Khadka 
Date:Mon Dec 18 16:17:04 2023 +0100

The script checkpatch.pl reported spelling errors
in ia_css_irq.h as below:

'''
WARNING: Possible repeated word: 'in'
/** the input system in in error */

WARNING: Possible repeated word: 'in'
/** the input formatter in in error */

WARNING: Possible repeated word: 'in'
/** the dma in in error */
'''

This patch corrects spelling errors,
changing "in" to "is" in all three comments.

Link: https://lore.kernel.org/r/20231218151704.449883-1-kdipendr...@gmail.com

Signed-off-by: Dipendra Khadka 
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/atomisp/pci/ia_css_irq.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

---

diff --git a/drivers/staging/media/atomisp/pci/ia_css_irq.h 
b/drivers/staging/media/atomisp/pci/ia_css_irq.h
index 26b1b3c8ba62..00e2fd1f9647 100644
--- a/drivers/staging/media/atomisp/pci/ia_css_irq.h
+++ b/drivers/staging/media/atomisp/pci/ia_css_irq.h
@@ -84,11 +84,11 @@ enum ia_css_irq_info {
IA_CSS_IRQ_INFO_ISP_BINARY_STATISTICS_READY   = BIT(17),
/** ISP binary statistics are ready */
IA_CSS_IRQ_INFO_INPUT_SYSTEM_ERROR= BIT(18),
-   /** the input system in in error */
+   /** the input system is in error */
IA_CSS_IRQ_INFO_IF_ERROR  = BIT(19),
-   /** the input formatter in in error */
+   /** the input formatter is in error */
IA_CSS_IRQ_INFO_DMA_ERROR = BIT(20),
-   /** the dma in in error */
+   /** the dma is in error */
IA_CSS_IRQ_INFO_ISYS_EVENTS_READY = BIT(21),
/** end-of-frame events are ready in the isys_event queue */
 };


[git:dtv-scan-tables/master] dtv-scan-tables: added channels for Lviv, Ukraine

2024-02-06 Thread Mauro Carvalho Chehab
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: dtv-scan-tables: added channels for Lviv, Ukraine
Author:  Kostyantyn Sushchyk 
Date:Tue Oct 17 10:07:15 2023 +0200

Add DVB-T2 channels for Lviv, Ukraine

Link: 
https://lore.kernel.org/linux-media/cakx9iskatha1qagklrfbkyqwpvwipeztch33xvqw3ryxtm+...@mail.gmail.com
Signed-off-by: Mauro Carvalho Chehab 

 dvb-t/ua-Lviv | 36 
 1 file changed, 36 insertions(+)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=5fd33878499c007433646cc8de32c224db5363e5
diff --git a/dvb-t/ua-Lviv b/dvb-t/ua-Lviv
new file mode 100644
index ..f09fdabf3c13
--- /dev/null
+++ b/dvb-t/ua-Lviv
@@ -0,0 +1,36 @@
+# Ukraine, Lviv
+[CHANNEL]
+DELIVERY_SYSTEM = DVBT2
+FREQUENCY = 48200
+BANDWIDTH_HZ = 800
+CODE_RATE_HP = 3/5
+CODE_RATE_LP = NONE
+MODULATION = QAM/256
+TRANSMISSION_MODE = 32K
+GUARD_INTERVAL = 1/16
+HIERARCHY = NONE
+INVERSION = AUTO
+
+[CHANNEL]
+DELIVERY_SYSTEM = DVBT2
+FREQUENCY = 53000
+BANDWIDTH_HZ = 800
+CODE_RATE_HP = 3/5
+CODE_RATE_LP = NONE
+MODULATION = QAM/256
+TRANSMISSION_MODE = 32K
+GUARD_INTERVAL = 1/16
+HIERARCHY = NONE
+INVERSION = AUTO
+
+[CHANNEL]
+DELIVERY_SYSTEM = DVBT2
+FREQUENCY = 62600
+BANDWIDTH_HZ = 800
+CODE_RATE_HP = 3/5
+CODE_RATE_LP = NONE
+MODULATION = QAM/256
+TRANSMISSION_MODE = 32K
+GUARD_INTERVAL = 1/16
+HIERARCHY = NONE
+INVERSION = AUTO


[git:media_stage/master] media: docs: uAPI: dvb/decoder: completing the documentation

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

Subject: media: docs: uAPI: dvb/decoder: completing the documentation
Author:  Stefan Herdler 
Date:Mon Jan 29 00:32:44 2024 +0100

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the new index file and links to it.

Link: 
https://lore.kernel.org/linux-media/20240128233249.32794-2-herd...@nurfuerspam.de
Signed-off-by: Stefan Herdler 
Signed-off-by: Mauro Carvalho Chehab 

 .../userspace-api/media/dvb/legacy_dvb_apis.rst|  1 +
 .../media/dvb/legacy_dvb_decoder_api.rst   | 61 ++
 2 files changed, 62 insertions(+)

---

diff --git a/Documentation/userspace-api/media/dvb/legacy_dvb_apis.rst 
b/Documentation/userspace-api/media/dvb/legacy_dvb_apis.rst
index b97d56ee543c..ffe8325749e5 100644
--- a/Documentation/userspace-api/media/dvb/legacy_dvb_apis.rst
+++ b/Documentation/userspace-api/media/dvb/legacy_dvb_apis.rst
@@ -23,3 +23,4 @@ DVB-S2, DVB-T2, ISDB, etc.
 :maxdepth: 1
 
 frontend_legacy_dvbv3_api
+legacy_dvb_decoder_api
diff --git a/Documentation/userspace-api/media/dvb/legacy_dvb_decoder_api.rst 
b/Documentation/userspace-api/media/dvb/legacy_dvb_decoder_api.rst
new file mode 100644
index ..f58985a6e63c
--- /dev/null
+++ b/Documentation/userspace-api/media/dvb/legacy_dvb_decoder_api.rst
@@ -0,0 +1,61 @@
+.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later OR GPL-2.0
+
+.. _legacy_dvb_decoder_api:
+
+
+Legacy DVB MPEG Decoder APIs
+
+
+.. _legacy_dvb_decoder_notes:
+
+General Notes
+=
+
+This API has originally been designed for DVB only and is therefore limited to
+the :ref:`legacy_dvb_decoder_formats` used in such digital TV-broadcastsystems.
+
+To circumvent this limitations the more versatile :ref:`V4L2 ` API 
has
+been designed. Which replaces this part of the DVB API.
+
+Nevertheless there have been projects build around this API.
+To ensure compatibility this API is kept as it is.
+
+.. attention:: Do **not** use this API in new drivers!
+
+For audio and video use the :ref:`V4L2 ` and ALSA APIs.
+
+Pipelines should be set up using the :ref:`Media Controller  
API`.
+
+Practically the decoders seem to be treated differently. The application 
typically
+knows which decoder is in use or it is specially written for one decoder type.
+Querying capabilities are rarely used because they are already known.
+
+
+.. _legacy_dvb_decoder_formats:
+
+Data Formats
+
+
+The API has been designed for DVB and compatible broadcastsystems.
+Because of that fact the only supported data formats are ISO/IEC 13818-1
+compatible MPEG streams. The supported payloads may vary depending on the
+used decoder.
+
+Timestamps are always MPEG PTS as defined in ITU T-REC-H.222.0 /
+ISO/IEC 13818-1, if not otherwise noted.
+
+For storing recordings typically TS streams are used, in lesser extent PES.
+Both variants are commonly accepted for playback, but it may be driver 
dependent.
+
+
+
+
+Table of Contents
+=
+
+.. toctree::
+:maxdepth: 2
+
+legacy_dvb_video
+legacy_dvb_audio
+legacy_dvb_osd


[git:media_stage/master] media: docs: uAPI: dvb/video: completing the documentation (data types)

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

Subject: media: docs: uAPI: dvb/video: completing the documentation (data types)
Author:  Stefan Herdler 
Date:Mon Jan 29 00:32:48 2024 +0100

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of the data types defined in
video.h.

Link: 
https://lore.kernel.org/linux-media/20240128233249.32794-6-herd...@nurfuerspam.de
Signed-off-by: Stefan Herdler 
Signed-off-by: Mauro Carvalho Chehab 

 .../userspace-api/media/dvb/legacy_dvb_video.rst   | 798 +
 1 file changed, 798 insertions(+)

---

diff --git a/Documentation/userspace-api/media/dvb/legacy_dvb_video.rst 
b/Documentation/userspace-api/media/dvb/legacy_dvb_video.rst
new file mode 100644
index ..40e002f507a9
--- /dev/null
+++ b/Documentation/userspace-api/media/dvb/legacy_dvb_video.rst
@@ -0,0 +1,798 @@
+.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later OR GPL-2.0
+
+.. c:namespace:: dtv.legacy.video
+
+.. _dvb_video:
+
+
+DVB Video Device
+
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+The DVB video device controls the MPEG2 video decoder of the DVB
+hardware. It can be accessed through ``/dev/dvb/adapter0/video0``. Data
+types and ioctl definitions can be accessed by including
+``linux/dvb/video.h`` in your application.
+
+Note that the DVB video device only controls decoding of the MPEG video
+stream, not its presentation on the TV or computer screen. On PCs this
+is typically handled by an associated video4linux device, e.g.
+``/dev/video``, which allows scaling and defining output windows.
+
+Most DVB cards don’t have their own MPEG decoder, which results in the
+omission of the audio and video device as well as the video4linux
+device.
+
+These ioctls were also used by V4L2 to control MPEG decoders implemented
+in V4L2. The use of these ioctls for that purpose has been made obsolete
+and proper V4L2 ioctls or controls have been created to replace that
+functionality. Use :ref:`V4L2 ioctls` for new drivers!
+
+
+Video Data Types
+
+
+
+
+video_format_t
+--
+
+Synopsis
+
+
+.. code-block:: c
+
+typedef enum {
+   VIDEO_FORMAT_4_3,
+   VIDEO_FORMAT_16_9,
+   VIDEO_FORMAT_221_1
+} video_format_t;
+
+Constants
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``VIDEO_FORMAT_4_3``
+
+   -  Select 4:3 format.
+
+-  ..
+
+   -  ``VIDEO_FORMAT_16_9``
+
+   -  Select 16:9 format.
+
+-  ..
+
+   -  ``VIDEO_FORMAT_221_1``
+
+   -  Select 2.21:1 format.
+
+Description
+~~~
+
+The ``video_format_t`` data type
+is used in the `VIDEO_SET_FORMAT`_ function to tell the driver which
+aspect ratio the output hardware (e.g. TV) has. It is also used in the
+data structures `video_status`_ returned by `VIDEO_GET_STATUS`_
+and `video_event`_ returned by `VIDEO_GET_EVENT`_ which report
+about the display format of the current video stream.
+
+
+-
+
+
+video_displayformat_t
+-
+
+Synopsis
+
+
+.. code-block:: c
+
+typedef enum {
+   VIDEO_PAN_SCAN,
+   VIDEO_LETTER_BOX,
+   VIDEO_CENTER_CUT_OUT
+} video_displayformat_t;
+
+Constants
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``VIDEO_PAN_SCAN``
+
+   -  Use pan and scan format.
+
+-  ..
+
+   -  ``VIDEO_LETTER_BOX``
+
+   -  Use letterbox format.
+
+-  ..
+
+   -  ``VIDEO_CENTER_CUT_OUT``
+
+   -  Use center cut out format.
+
+Description
+~~~
+
+In case the display format of the video stream and of the display
+hardware differ the application has to specify how to handle the
+cropping of the picture. This can be done using the
+`VIDEO_SET_DISPLAY_FORMAT`_ call which accepts this enum as argument.
+
+
+-
+
+
+video_size_t
+
+
+Synopsis
+
+
+.. code-block:: c
+
+typedef struct {
+   int w;
+   int h;
+   video_format_t aspect_ratio;
+} video_size_t;
+
+Variables
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``int w``
+
+   -  Video width in pixels.
+
+-  ..
+
+   -  ``int h``
+
+   -  Video height in pixels.
+
+-  ..
+
+   -  `video_format_t`_ ``aspect_ratio``
+
+   -  Aspect ratio.
+
+Description
+~~~
+
+Used in the struct `video_event`_. It stores the resolution and
+aspect ratio of the video.
+
+
+-
+
+
+video_stream_source_t
+-
+
+Synopsis
+
+
+.. code-block:: c
+
+typedef enum {
+   VIDEO_SOURCE_DEMUX,
+   VIDEO_SOURCE_MEMORY
+} video_stream_source_t;
+
+Constants
+~
+
+.. fla

[git:media_stage/master] media: docs: uAPI: dvb/audio: completing the documentation (data types)

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

Subject: media: docs: uAPI: dvb/audio: completing the documentation (data types)
Author:  Stefan Herdler 
Date:Mon Jan 29 00:32:46 2024 +0100

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of the data types defined in
audio.h.

Link: 
https://lore.kernel.org/linux-media/20240128233249.32794-4-herd...@nurfuerspam.de
Signed-off-by: Stefan Herdler 
Signed-off-by: Mauro Carvalho Chehab 

 .../userspace-api/media/dvb/legacy_dvb_audio.rst   | 447 +
 1 file changed, 447 insertions(+)

---

diff --git a/Documentation/userspace-api/media/dvb/legacy_dvb_audio.rst 
b/Documentation/userspace-api/media/dvb/legacy_dvb_audio.rst
new file mode 100644
index ..d15088748f55
--- /dev/null
+++ b/Documentation/userspace-api/media/dvb/legacy_dvb_audio.rst
@@ -0,0 +1,447 @@
+.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later OR GPL-2.0
+
+.. c:namespace:: dtv.legacy.audio
+
+.. _dvb_audio:
+
+
+DVB Audio Device
+
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+The DVB audio device controls the MPEG2 audio decoder of the DVB
+hardware. It can be accessed through ``/dev/dvb/adapter?/audio?``. Data
+types and ioctl definitions can be accessed by including
+``linux/dvb/audio.h`` in your application.
+
+Please note that most DVB cards don’t have their own MPEG decoder, which
+results in the omission of the audio and video device.
+
+These ioctls were also used by V4L2 to control MPEG decoders implemented
+in V4L2. The use of these ioctls for that purpose has been made obsolete
+and proper V4L2 ioctls or controls have been created to replace that
+functionality. Use :ref:`V4L2 ioctls` for new drivers!
+
+
+Audio Data Types
+
+
+This section describes the structures, data types and defines used when
+talking to the audio device.
+
+
+-
+
+
+audio_stream_source_t
+-
+
+Synopsis
+
+
+.. c:enum:: audio_stream_source_t
+
+.. code-block:: c
+
+typedef enum {
+AUDIO_SOURCE_DEMUX,
+AUDIO_SOURCE_MEMORY
+} audio_stream_source_t;
+
+Constants
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``AUDIO_SOURCE_DEMUX``
+
+   -  :cspan:`1` Selects the demultiplexer (fed either by the frontend
+  or the DVR device) as the source of the video stream.
+
+-  ..
+
+   -  ``AUDIO_SOURCE_MEMORY``
+
+   -  Selects the stream from the application that comes through
+  the `write()`_ system call.
+
+Description
+~~~
+
+The audio stream source is set through the `AUDIO_SELECT_SOURCE`_ call
+and can take the following values, depending on whether we are replaying
+from an internal (demux) or external (user write) source.
+
+The data fed to the decoder is also controlled by the PID-filter.
+Output selection: :c:type:`dmx_output` ``DMX_OUT_DECODER``.
+
+
+-
+
+
+audio_play_state_t
+--
+
+Synopsis
+
+
+.. c:enum:: audio_play_state_t
+
+.. code-block:: c
+
+typedef enum {
+   AUDIO_STOPPED,
+   AUDIO_PLAYING,
+   AUDIO_PAUSED
+} audio_play_state_t;
+
+Constants
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``AUDIO_STOPPED``
+
+   -  Audio is stopped.
+
+-  ..
+
+   -  ``AUDIO_PLAYING``
+
+   -  Audio is currently playing.
+
+-  ..
+
+   -  ``AUDIO_PAUSE``
+
+   -  Audio is frozen.
+
+Description
+~~~
+
+This values can be returned by the `AUDIO_GET_STATUS`_ call
+representing the state of audio playback.
+
+
+-
+
+
+audio_channel_select_t
+--
+
+Synopsis
+
+
+.. c:enum:: audio_channel_select_t
+
+.. code-block:: c
+
+typedef enum {
+   AUDIO_STEREO,
+   AUDIO_MONO_LEFT,
+   AUDIO_MONO_RIGHT,
+   AUDIO_MONO,
+   AUDIO_STEREO_SWAPPED
+} audio_channel_select_t;
+
+Constants
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``AUDIO_STEREO``
+
+   -  Stereo.
+
+-  ..
+
+   -  ``AUDIO_MONO_LEFT``
+
+   -  Mono, select left stereo channel as source.
+
+-  ..
+
+   -  ``AUDIO_MONO_RIGHT``
+
+   -  Mono, select right stereo channel as source.
+
+-  ..
+
+   -  ``AUDIO_MONO``
+
+   -  Mono source only.
+
+-  ..
+
+   -  ``AUDIO_STEREO_SWAPPED``
+
+   -  Stereo, swap L & R.
+
+Description
+~~~
+
+The audio channel selected via `AUDIO_CHANNEL_SELECT`_ is determined by
+this values.
+
+
+-
+
+
+audio_mixer_t
+-
+
+Synopsis
+
+
+.. c:struct:: audio_mixer
+
+.. code-block:: c
+
+typedef struct audio_mixer {
+   unsigned

[git:media_stage/master] media: edia: dvbdev: fix a use-after-free

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

Subject: media: edia: dvbdev: fix a use-after-free
Author:  Zhipeng Lu 
Date:Sat Feb 3 14:40:43 2024 +0100

In dvb_register_device, *pdvbdev is set equal to dvbdev, which is freed
in several error-handling paths. However, *pdvbdev is not set to NULL
after dvbdev's deallocation, causing use-after-frees in many places,
for example, in the following call chain:

budget_register
  |-> dvb_dmxdev_init
|-> dvb_register_device
  |-> dvb_dmxdev_release
|-> dvb_unregister_device
  |-> dvb_remove_device
|-> dvb_device_put
  |-> kref_put

When calling dvb_unregister_device, dmxdev->dvbdev (i.e. *pdvbdev in
dvb_register_device) could point to memory that had been freed in
dvb_register_device. Thereafter, this pointer is transferred to
kref_put and triggering a use-after-free.

Link: 
https://lore.kernel.org/linux-media/20240203134046.3120099-1-alexi...@zju.edu.cn
Fixes: b61901024776 ("V4L/DVB (5244): Dvbdev: fix illegal re-usage of 
fileoperations struct")
Signed-off-by: Zhipeng Lu 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/dvb-core/dvbdev.c | 5 +
 1 file changed, 5 insertions(+)

---

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 49f0eb7d0b9d..733d0bc4b4cc 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -490,6 +490,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct 
dvb_device **pdvbdev,
dvbdevfops = kmemdup(template->fops, sizeof(*dvbdevfops), 
GFP_KERNEL);
if (!dvbdevfops) {
kfree(dvbdev);
+   *pdvbdev = NULL;
mutex_unlock(&dvbdev_register_lock);
return -ENOMEM;
}
@@ -498,6 +499,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct 
dvb_device **pdvbdev,
if (!new_node) {
kfree(dvbdevfops);
kfree(dvbdev);
+   *pdvbdev = NULL;
mutex_unlock(&dvbdev_register_lock);
return -ENOMEM;
}
@@ -531,6 +533,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct 
dvb_device **pdvbdev,
}
list_del(&dvbdev->list_head);
kfree(dvbdev);
+   *pdvbdev = NULL;
up_write(&minor_rwsem);
mutex_unlock(&dvbdev_register_lock);
return -EINVAL;
@@ -553,6 +556,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct 
dvb_device **pdvbdev,
dvb_media_device_free(dvbdev);
list_del(&dvbdev->list_head);
kfree(dvbdev);
+   *pdvbdev = NULL;
mutex_unlock(&dvbdev_register_lock);
return ret;
}
@@ -571,6 +575,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct 
dvb_device **pdvbdev,
dvb_media_device_free(dvbdev);
list_del(&dvbdev->list_head);
kfree(dvbdev);
+   *pdvbdev = NULL;
mutex_unlock(&dvbdev_register_lock);
return PTR_ERR(clsdev);
}


[git:media_stage/master] media: docs: uAPI: dvb/osd: completing the documentation

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

Subject: media: docs: uAPI: dvb/osd: completing the documentation
Author:  Stefan Herdler 
Date:Mon Jan 29 00:32:45 2024 +0100

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of osd.h.

Link: 
https://lore.kernel.org/linux-media/20240128233249.32794-3-herd...@nurfuerspam.de
Signed-off-by: Stefan Herdler 
Signed-off-by: Mauro Carvalho Chehab 

 .../userspace-api/media/dvb/legacy_dvb_osd.rst | 883 +
 1 file changed, 883 insertions(+)

---

diff --git a/Documentation/userspace-api/media/dvb/legacy_dvb_osd.rst 
b/Documentation/userspace-api/media/dvb/legacy_dvb_osd.rst
new file mode 100644
index ..179b66a8016a
--- /dev/null
+++ b/Documentation/userspace-api/media/dvb/legacy_dvb_osd.rst
@@ -0,0 +1,883 @@
+.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later OR GPL-2.0
+
+.. c:namespace:: dtv.legacy.osd
+
+.. _dvb_osd:
+
+==
+DVB OSD Device
+==
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+The DVB OSD device controls the OnScreen-Display of the AV7110 based
+DVB-cards with hardware MPEG2 decoder. It can be accessed through
+``/dev/dvb/adapter?/osd0``.
+Data types and ioctl definitions can be accessed by including
+``linux/dvb/osd.h`` in your application.
+
+The OSD is not a frame-buffer like on many other cards.
+It is a kind of canvas one can draw on.
+The color-depth is limited depending on the memory size installed.
+An appropriate palette of colors has to be set up.
+The installed memory size can be identified with the `OSD_GET_CAPABILITY`_
+ioctl.
+
+OSD Data Types
+==
+
+OSD_Command
+---
+
+Synopsis
+
+
+.. code-block:: c
+
+typedef enum {
+   /* All functions return -2 on "not open" */
+   OSD_Close = 1,
+   OSD_Open,
+   OSD_Show,
+   OSD_Hide,
+   OSD_Clear,
+   OSD_Fill,
+   OSD_SetColor,
+   OSD_SetPalette,
+   OSD_SetTrans,
+   OSD_SetPixel,
+   OSD_GetPixel,
+   OSD_SetRow,
+   OSD_SetBlock,
+   OSD_FillRow,
+   OSD_FillBlock,
+   OSD_Line,
+   OSD_Query,
+   OSD_Test,
+   OSD_Text,
+   OSD_SetWindow,
+   OSD_MoveWindow,
+   OSD_OpenRaw,
+} OSD_Command;
+
+Commands
+
+
+.. note::  All functions return -2 on "not open"
+
+.. flat-table::
+:header-rows:  1
+:stub-columns: 0
+
+-  ..
+
+   -  Command
+
+   -  | Used variables of ``struct`` `osd_cmd_t`_.
+  | Usage{variable} if alternative use.
+
+   -  :cspan:`2` Description
+
+
+
+-  ..
+
+   -  ``OSD_Close``
+
+   -  -
+
+   -  | Disables OSD and releases the buffers.
+  | Returns 0 on success.
+
+-  ..
+
+   -  ``OSD_Open``
+
+   -  | x0,y0,x1,y1,
+  | BitPerPixel[2/4/8]{color&0x0F},
+  | mix[0..15]{color&0xF0}
+
+   -  | Opens OSD with this size and bit depth
+  | Returns 0 on success,
+  | -1 on DRAM allocation error,
+  | -2 on "already open".
+
+-  ..
+
+   -  ``OSD_Show``
+
+   - -
+
+   -  | Enables OSD mode.
+  | Returns 0 on success.
+
+-  ..
+
+   -  ``OSD_Hide``
+
+   - -
+
+   -  | Disables OSD mode.
+  | Returns 0 on success.
+
+-  ..
+
+   -  ``OSD_Clear``
+
+   - -
+
+   -  | Sets all pixel to color 0.
+  | Returns 0 on success.
+
+-  ..
+
+   -  ``OSD_Fill``
+
+   -  color
+
+   -  | Sets all pixel to color .
+  | Returns 0 on success.
+
+-  ..
+
+   -  ``OSD_SetColor``
+
+   -  | color,
+  | R{x0},G{y0},B{x1},
+  | opacity{y1}
+
+   -  | Set palette entry  to ,  and  apply
+  | R,G,B: 0..255
+  | R=Red, G=Green, B=Blue
+  | opacity=0:  pixel opacity 0% (only video pixel shows)
+  | opacity=1..254: pixel opacity as specified in header
+  | opacity=255:pixel opacity 100% (only OSD pixel shows)
+  | Returns 0 on success, -1 on error.
+
+-  ..
+
+   -  ``OSD_SetPalette``
+
+   -  | firstcolor{color},
+  | lastcolor{x0},data
+
+   -  | Set a number of entries in the palette.
+  | Sets the entries "firstcolor" through "lastcolor" from the
+array "data".
+  | Data has 4 byte for each color:
+  | R,G,B, and a opacity value: 0->transparent, 1..254->mix,
+255->pixel
+
+-  ..
+
+   -  ``OSD_SetTrans``
+
+   -  transparency{color}
+
+   -  | Sets transparency of mixed pixel (0..15).
+  | Returns 0 on success.
+
+-  ..
+
+   -  ``OSD_SetPixel``
+
+   -  x0,y0,color
+
+   -  | Sets pixel , to color number .
+  | Returns 0 on success, 

[git:media_stage/master] media: dvb: remove redundant assignment to variable ret

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

Subject: media: dvb: remove redundant assignment to variable ret
Author:  Colin Ian King 
Date:Tue Jan 16 12:50:02 2024 +0100

The variable ret is being assigned a value but it isn't being
read afterwards. The assignment is redundant and so ret can be
removed. Also add spaces after , to clean up checkpatch warnings.

Cleans up clang scan build warning:
warning: Although the value stored to 'ret' is used in the
enclosing expression, the value is never actually read from
'ret' [deadcode.DeadStores]

Link: 
https://lore.kernel.org/linux-media/20240116115002.2265367-1-colin.i.k...@gmail.com
Signed-off-by: Colin Ian King 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/dvb-frontends/bcm3510.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

---

diff --git a/drivers/media/dvb-frontends/bcm3510.c 
b/drivers/media/dvb-frontends/bcm3510.c
index b3f5c49accaf..27f1de21f571 100644
--- a/drivers/media/dvb-frontends/bcm3510.c
+++ b/drivers/media/dvb-frontends/bcm3510.c
@@ -797,7 +797,6 @@ struct dvb_frontend* bcm3510_attach(const struct 
bcm3510_config *config,
   struct i2c_adapter *i2c)
 {
struct bcm3510_state* state = NULL;
-   int ret;
bcm3510_register_value v;
 
/* allocate memory for the internal state */
@@ -816,7 +815,7 @@ struct dvb_frontend* bcm3510_attach(const struct 
bcm3510_config *config,
 
mutex_init(&state->hab_mutex);
 
-   if ((ret = bcm3510_readB(state,0xe0,&v)) < 0)
+   if (bcm3510_readB(state, 0xe0, &v) < 0)
goto error;
 
deb_info("Revision: 0x%1x, Layer: 
0x%1x.\n",v.REVID_e0.REV,v.REVID_e0.LAYER);


[git:media_stage/master] media: cx24110: clean up some coding style issues

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

Subject: media: cx24110: clean up some coding style issues
Author:  XueBing Chen 
Date:Thu Jan 11 11:58:56 2024 +0100

Fix the following errors reported by checkpatch:

ERROR: "foo* bar" should be "foo *bar"
ERROR: spaces required around that '=' (ctx:VxV)
ERROR: space required after that ',' (ctx:VxV)

Link: 
https://lore.kernel.org/linux-media/2024005856.14655-1-chenxb_99...@126.com
Signed-off-by: XueBing Chen 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/dvb-frontends/cx24110.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

diff --git a/drivers/media/dvb-frontends/cx24110.c 
b/drivers/media/dvb-frontends/cx24110.c
index 9aeea089756f..65dd9b72ea55 100644
--- a/drivers/media/dvb-frontends/cx24110.c
+++ b/drivers/media/dvb-frontends/cx24110.c
@@ -224,13 +224,13 @@ static enum fe_code_rate cx24110_get_fec(struct 
cx24110_state *state)
}
 }
 
-static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate)
+static int cx24110_set_symbolrate (struct cx24110_state *state, u32 srate)
 {
 /* fixme (low): add error handling */
u32 ratio;
u32 tmp, fclk, BDRI;
 
-   static const u32 bands[]={500UL,1500UL,90999000UL/2};
+   static const u32 bands[] = {500UL, 1500UL, 90999000UL/2};
int i;
 
dprintk("cx24110 debug: entering %s(%d)\n",__func__,srate);


[git:media_stage/master] media: docs: uAPI: dvb/video: completing the documentation (function calls)

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

Subject: media: docs: uAPI: dvb/video: completing the documentation (function 
calls)
Author:  Stefan Herdler 
Date:Mon Jan 29 00:32:49 2024 +0100

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of the function calls defined in
video.h.

Link: 
https://lore.kernel.org/linux-media/20240128233249.32794-7-herd...@nurfuerspam.de
Signed-off-by: Stefan Herdler 
Signed-off-by: Mauro Carvalho Chehab 

 .../userspace-api/media/dvb/legacy_dvb_video.rst   | 1632 
 1 file changed, 1632 insertions(+)

---

diff --git a/Documentation/userspace-api/media/dvb/legacy_dvb_video.rst 
b/Documentation/userspace-api/media/dvb/legacy_dvb_video.rst
index 40e002f507a9..b9fd5cadae24 100644
--- a/Documentation/userspace-api/media/dvb/legacy_dvb_video.rst
+++ b/Documentation/userspace-api/media/dvb/legacy_dvb_video.rst
@@ -796,3 +796,1635 @@ Description
 
 A call to `VIDEO_GET_CAPABILITIES`_ returns an unsigned integer with the
 following bits set according to the hardware's capabilities.
+
+
+-
+
+
+Video Function Calls
+
+
+
+VIDEO_STOP
+--
+
+Synopsis
+
+
+.. c:macro:: VIDEO_STOP
+
+.. code-block:: c
+
+   int ioctl(fd, VIDEO_STOP, int mode)
+
+Arguments
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``int fd``
+
+   -  :cspan:`1` File descriptor returned by a previous call
+  to `open()`_.
+
+-  ..
+
+   -  ``int request``
+
+   -  :cspan:`1` Equals ``VIDEO_STOP`` for this command.
+
+-  ..
+
+   -  :rspan:`2` ``int mode``
+
+   -  :cspan:`1` Indicates how the screen shall be handled.
+
+-  ..
+
+   -  TRUE  ( != 0 )
+
+   -  Blank screen when stop.
+
+-  ..
+
+   -  FALSE ( == 0 )
+
+   -  Show last decoded frame.
+
+Description
+~~~
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+This ioctl is for Digital TV devices only. To control a V4L2 decoder use
+the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
+
+This ioctl call asks the Video Device to stop playing the current
+stream. Depending on the input parameter, the screen can be blanked out
+or displaying the last decoded frame.
+
+Return Value
+
+
+On success 0 is returned, on error -1 and the ``errno`` variable is set
+appropriately. The generic error codes are described at the
+:ref:`Generic Error Codes ` chapter.
+
+
+-
+
+
+VIDEO_PLAY
+--
+
+Synopsis
+
+
+.. c:macro:: VIDEO_PLAY
+
+.. code-block:: c
+
+   int ioctl(fd, VIDEO_PLAY)
+
+Arguments
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``int fd``
+
+   -  :cspan:`1` File descriptor returned by a previous call
+  to `open()`_.
+
+-  ..
+
+   -  ``int request``
+
+   -  Equals ``VIDEO_PLAY`` for this command.
+
+Description
+~~~
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+This ioctl is for Digital TV devices only. To control a V4L2 decoder use
+the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
+
+This ioctl call asks the Video Device to start playing a video stream
+from the selected source.
+
+Return Value
+
+
+On success 0 is returned, on error -1 and the ``errno`` variable is set
+appropriately. The generic error codes are described at the
+:ref:`Generic Error Codes ` chapter.
+
+
+-
+
+
+VIDEO_FREEZE
+
+
+Synopsis
+
+
+.. c:macro:: VIDEO_FREEZE
+
+.. code-block:: c
+
+   int ioctl(fd, VIDEO_FREEZE)
+
+Arguments
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``int fd``
+
+   -  :cspan:`1` File descriptor returned by a previous call
+  to `open()`_.
+
+-  ..
+
+   -  ``int request``
+
+   -  Equals ``VIDEO_FREEZE`` for this command.
+
+Description
+~~~
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+This ioctl is for Digital TV devices only. To control a V4L2 decoder use
+the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
+
+This ioctl call suspends the live video stream being played, if
+VIDEO_SOURCE_DEMUX is selected. Decoding and playing are frozen.
+It is then possible to restart the decoding and playing process of the
+video stream using the `VIDEO_CONTINUE`_ command.
+If VIDEO_SOURCE_MEMORY is selected in the ioctl call
+`VIDEO_SELECT_SOURCE`_, the Digital TV subsystem will not decode any more
+data until the ioctl call `VIDEO_CONTINUE`_ or `VIDEO_PLAY`_ is performed.
+
+Return Value
+
+
+On success 0 is returned, on error -1 and the ``errno`` variable is set
+appropriately. The ge

[git:media_stage/master] media: docs: uAPI: dvb/audio: completing the documentation (function calls)

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

Subject: media: docs: uAPI: dvb/audio: completing the documentation (function 
calls)
Author:  Stefan Herdler 
Date:Mon Jan 29 00:32:47 2024 +0100

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of the function calls defined in
audio.h.

Link: 
https://lore.kernel.org/linux-media/20240128233249.32794-5-herd...@nurfuerspam.de
Signed-off-by: Stefan Herdler 
Signed-off-by: Mauro Carvalho Chehab 

 .../userspace-api/media/dvb/legacy_dvb_audio.rst   | 1195 
 1 file changed, 1195 insertions(+)

---

diff --git a/Documentation/userspace-api/media/dvb/legacy_dvb_audio.rst 
b/Documentation/userspace-api/media/dvb/legacy_dvb_audio.rst
index d15088748f55..b46fe2becd02 100644
--- a/Documentation/userspace-api/media/dvb/legacy_dvb_audio.rst
+++ b/Documentation/userspace-api/media/dvb/legacy_dvb_audio.rst
@@ -445,3 +445,1198 @@ Description
 
 A call to `AUDIO_GET_CAPABILITIES`_ returns an unsigned integer with the
 following bits set according to the hardwares capabilities.
+
+
+-
+
+
+Audio Function Calls
+
+
+
+AUDIO_STOP
+--
+
+Synopsis
+
+
+.. c:macro:: AUDIO_STOP
+
+.. code-block:: c
+
+int ioctl(int fd, int request = AUDIO_STOP)
+
+Arguments
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``int fd``
+
+   -  File descriptor returned by a previous call to `open()`_.
+
+-  ..
+
+   -  ``int request``
+
+   -  :cspan:`1` Equals ``AUDIO_STOP`` for this command.
+
+Description
+~~~
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+This ioctl call asks the Audio Device to stop playing the current
+stream.
+
+Return Value
+
+
+On success 0 is returned, on error -1 and the ``errno`` variable is set
+appropriately. The generic error codes are described at the
+:ref:`Generic Error Codes ` chapter.
+
+
+-
+
+
+AUDIO_PLAY
+--
+
+Synopsis
+
+
+.. c:macro:: AUDIO_PLAY
+
+.. code-block:: c
+
+int  ioctl(int fd, int request = AUDIO_PLAY)
+
+Arguments
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``int fd``
+
+   -  File descriptor returned by a previous call to `open()`_.
+
+-  ..
+
+   -  ``int request``
+
+   -  :cspan:`1` Equals ``AUDIO_PLAY`` for this command.
+
+Description
+~~~
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+This ioctl call asks the Audio Device to start playing an audio stream
+from the selected source.
+
+Return Value
+
+
+On success 0 is returned, on error -1 and the ``errno`` variable is set
+appropriately. The generic error codes are described at the
+:ref:`Generic Error Codes ` chapter.
+
+
+-
+
+
+AUDIO_PAUSE
+---
+
+Synopsis
+
+
+.. c:macro:: AUDIO_PAUSE
+
+.. code-block:: c
+
+int  ioctl(int fd, int request = AUDIO_PAUSE)
+
+Arguments
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``int fd``
+
+   -  :cspan:`1` File descriptor returned by a previous call
+  to `open()`_.
+
+-  ..
+
+   -  ``int request``
+
+   -  Equals ``AUDIO_PAUSE`` for this command.
+
+Description
+~~~
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+This ioctl call suspends the audio stream being played. Decoding and
+playing are paused. It is then possible to restart again decoding and
+playing process of the audio stream using `AUDIO_CONTINUE`_ command.
+
+Return Value
+
+
+On success 0 is returned, on error -1 and the ``errno`` variable is set
+appropriately. The generic error codes are described at the
+:ref:`Generic Error Codes ` chapter.
+
+
+-
+
+
+AUDIO_CONTINUE
+--
+
+Synopsis
+
+
+.. c:macro:: AUDIO_CONTINUE
+
+.. code-block:: c
+
+int  ioctl(int fd, int request = AUDIO_CONTINUE)
+
+Arguments
+~
+
+.. flat-table::
+:header-rows:  0
+:stub-columns: 0
+
+-  ..
+
+   -  ``int fd``
+
+   -  :cspan:`1` File descriptor returned by a previous call
+  to `open()`_.
+
+-  ..
+
+   -  ``int request``
+
+   -  Equals ``AUDIO_CONTINUE`` for this command.
+
+Description
+~~~
+
+.. attention:: Do **not** use in new drivers!
+ See: :ref:`legacy_dvb_decoder_notes`
+
+This ioctl restarts the decoding and playing process previously paused
+with `AUDIO_PAUSE`_ command.
+
+Return Value
+
+
+On success 0 is returned, on error -1 and the ``errno`` variable is set
+appropriately. The generic error codes are described at the
+:ref

[git:media_stage/master] media: dvb-frontends/dvb-pll: Remove usage of the deprecated ida_simple_xx() API

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

Subject: media: dvb-frontends/dvb-pll: Remove usage of the deprecated 
ida_simple_xx() API
Author:  Christophe JAILLET 
Date:Thu Jan 11 22:33:44 2024 +0100

ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_max() is inclusive. So a -1 has been added when needed.

Link: 
https://lore.kernel.org/linux-media/920639b9e05775eea56ecb9cd5ed38ad292a96a8.1705008803.git.christophe.jail...@wanadoo.fr
Signed-off-by: Christophe JAILLET 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/dvb-frontends/dvb-pll.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

---

diff --git a/drivers/media/dvb-frontends/dvb-pll.c 
b/drivers/media/dvb-frontends/dvb-pll.c
index ef697ab6bc2e..1775a4aa0a18 100644
--- a/drivers/media/dvb-frontends/dvb-pll.c
+++ b/drivers/media/dvb-frontends/dvb-pll.c
@@ -796,7 +796,7 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend 
*fe, int pll_addr,
b1[0] = 0;
msg.buf = b1;
 
-   nr = ida_simple_get(&pll_ida, 0, DVB_PLL_MAX, GFP_KERNEL);
+   nr = ida_alloc_max(&pll_ida, DVB_PLL_MAX - 1, GFP_KERNEL);
if (nr < 0) {
kfree(b1);
return NULL;
@@ -862,7 +862,7 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend 
*fe, int pll_addr,
return fe;
 out:
kfree(b1);
-   ida_simple_remove(&pll_ida, nr);
+   ida_free(&pll_ida, nr);
 
return NULL;
 }
@@ -905,7 +905,7 @@ static void dvb_pll_remove(struct i2c_client *client)
struct dvb_frontend *fe = i2c_get_clientdata(client);
struct dvb_pll_priv *priv = fe->tuner_priv;
 
-   ida_simple_remove(&pll_ida, priv->nr);
+   ida_free(&pll_ida, priv->nr);
dvb_pll_release(fe);
 }
 


[git:media_stage/master] media: drivers/media/dvb-core: copy user arrays safely

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

Subject: media: drivers/media/dvb-core: copy user arrays safely
Author:  Philipp Stanner 
Date:Thu Nov 2 20:16:34 2023 +0100

At several positions in dvb_frontend.c, memdup_user() is utilized to
copy userspace arrays. This is done without overflow checks.

Use the new wrapper memdup_array_user() to copy the arrays more safely.

Link: 
https://lore.kernel.org/linux-media/20231102191633.52592-2-pstan...@redhat.com
Suggested-by: Dave Airlie 
Signed-off-by: Philipp Stanner 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/dvb-core/dvb_frontend.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

---

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index 9293b058ab99..93d3378a0df4 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -2168,7 +2168,8 @@ static int dvb_frontend_handle_compat_ioctl(struct file 
*file, unsigned int cmd,
if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
return -EINVAL;
 
-   tvp = memdup_user(compat_ptr(tvps->props), tvps->num * 
sizeof(*tvp));
+   tvp = memdup_array_user(compat_ptr(tvps->props),
+   tvps->num, sizeof(*tvp));
if (IS_ERR(tvp))
return PTR_ERR(tvp);
 
@@ -2199,7 +2200,8 @@ static int dvb_frontend_handle_compat_ioctl(struct file 
*file, unsigned int cmd,
if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
return -EINVAL;
 
-   tvp = memdup_user(compat_ptr(tvps->props), tvps->num * 
sizeof(*tvp));
+   tvp = memdup_array_user(compat_ptr(tvps->props),
+   tvps->num, sizeof(*tvp));
if (IS_ERR(tvp))
return PTR_ERR(tvp);
 
@@ -2379,7 +2381,8 @@ static int dvb_get_property(struct dvb_frontend *fe, 
struct file *file,
if (!tvps->num || tvps->num > DTV_IOCTL_MAX_MSGS)
return -EINVAL;
 
-   tvp = memdup_user((void __user *)tvps->props, tvps->num * sizeof(*tvp));
+   tvp = memdup_array_user((void __user *)tvps->props,
+   tvps->num, sizeof(*tvp));
if (IS_ERR(tvp))
return PTR_ERR(tvp);
 
@@ -2457,7 +2460,8 @@ static int dvb_frontend_handle_ioctl(struct file *file,
if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
return -EINVAL;
 
-   tvp = memdup_user((void __user *)tvps->props, tvps->num * 
sizeof(*tvp));
+   tvp = memdup_array_user((void __user *)tvps->props,
+   tvps->num, sizeof(*tvp));
if (IS_ERR(tvp))
return PTR_ERR(tvp);