]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: qcom: camss: Add an id property to struct resources
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Fri, 14 Mar 2025 23:35:54 +0000 (23:35 +0000)
committerHans Verkuil <hverkuil@xs4all.nl>
Fri, 11 Apr 2025 11:29:06 +0000 (13:29 +0200)
In various places in CAMSS we assume a linear set of declared devices
{csiphy0, csiphy1, csiphy2} which currently works for upstream SoCs but for
upcoming SoCs some of the SoC resources will result in a set such as
{csiphy0, csiphy2} which will break the naive for() loops we have.

Introduce an identity property which resource declarations can populate
hence facilitating non-linear resource naming.

Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/qcom/camss/camss-csiphy.h
drivers/media/platform/qcom/camss/camss.c

index 86b98b37838e11d43d642c3f24e9a66acddabd03..ab91273303b9e3c67c4bcefe1e3a67e1a47bf14f 100644 (file)
@@ -81,6 +81,7 @@ struct csiphy_hw_ops {
 };
 
 struct csiphy_subdev_resources {
+       u8 id;
        const struct csiphy_hw_ops *hw_ops;
        const struct csiphy_formats *formats;
 };
index 8fcfe06449bf91a7b43aeb90371d0468d2831caf..d7e0e802852a22d0e2dd849c50be6c4c58e19f38 100644 (file)
@@ -46,6 +46,7 @@ static const struct camss_subdev_resources csiphy_res_8x16[] = {
                .reg = { "csiphy0", "csiphy0_clk_mux" },
                .interrupt = { "csiphy0" },
                .csiphy = {
+                       .id = 0,
                        .hw_ops = &csiphy_ops_2ph_1_0,
                        .formats = &csiphy_formats_8x16
                }
@@ -62,6 +63,7 @@ static const struct camss_subdev_resources csiphy_res_8x16[] = {
                .reg = { "csiphy1", "csiphy1_clk_mux" },
                .interrupt = { "csiphy1" },
                .csiphy = {
+                       .id = 1,
                        .hw_ops = &csiphy_ops_2ph_1_0,
                        .formats = &csiphy_formats_8x16
                }
@@ -318,6 +320,7 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
                .reg = { "csiphy0", "csiphy0_clk_mux" },
                .interrupt = { "csiphy0" },
                .csiphy = {
+                       .id = 0,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_8x96
                }
@@ -334,6 +337,7 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
                .reg = { "csiphy1", "csiphy1_clk_mux" },
                .interrupt = { "csiphy1" },
                .csiphy = {
+                       .id = 1,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_8x96
                }
@@ -350,6 +354,7 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
                .reg = { "csiphy2", "csiphy2_clk_mux" },
                .interrupt = { "csiphy2" },
                .csiphy = {
+                       .id = 2,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_8x96
                }
@@ -524,6 +529,7 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
                .reg = { "csiphy0", "csiphy0_clk_mux" },
                .interrupt = { "csiphy0" },
                .csiphy = {
+                       .id = 0,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_8x96
                }
@@ -542,6 +548,7 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
                .reg = { "csiphy1", "csiphy1_clk_mux" },
                .interrupt = { "csiphy1" },
                .csiphy = {
+                       .id = 1,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_8x96
                }
@@ -560,6 +567,7 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
                .reg = { "csiphy2", "csiphy2_clk_mux" },
                .interrupt = { "csiphy2" },
                .csiphy = {
+                       .id = 2,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_8x96
                }
@@ -751,6 +759,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
                .reg = { "csiphy0" },
                .interrupt = { "csiphy0" },
                .csiphy = {
+                       .id = 0,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -768,6 +777,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
                .reg = { "csiphy1" },
                .interrupt = { "csiphy1" },
                .csiphy = {
+                       .id = 1,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -785,6 +795,7 @@ static const struct camss_subdev_resources csiphy_res_670[] = {
                .reg = { "csiphy2" },
                .interrupt = { "csiphy2" },
                .csiphy = {
+                       .id = 2,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -935,6 +946,7 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
                .reg = { "csiphy0" },
                .interrupt = { "csiphy0" },
                .csiphy = {
+                       .id = 0,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -957,6 +969,7 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
                .reg = { "csiphy1" },
                .interrupt = { "csiphy1" },
                .csiphy = {
+                       .id = 1,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -979,6 +992,7 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
                .reg = { "csiphy2" },
                .interrupt = { "csiphy2" },
                .csiphy = {
+                       .id = 2,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1001,6 +1015,7 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
                .reg = { "csiphy3" },
                .interrupt = { "csiphy3" },
                .csiphy = {
+                       .id = 3,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1179,6 +1194,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
                .reg = { "csiphy0" },
                .interrupt = { "csiphy0" },
                .csiphy = {
+                       .id = 0,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1192,6 +1208,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
                .reg = { "csiphy1" },
                .interrupt = { "csiphy1" },
                .csiphy = {
+                       .id = 1,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1205,6 +1222,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
                .reg = { "csiphy2" },
                .interrupt = { "csiphy2" },
                .csiphy = {
+                       .id = 2,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1218,6 +1236,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
                .reg = { "csiphy3" },
                .interrupt = { "csiphy3" },
                .csiphy = {
+                       .id = 3,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1231,6 +1250,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
                .reg = { "csiphy4" },
                .interrupt = { "csiphy4" },
                .csiphy = {
+                       .id = 4,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1244,6 +1264,7 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
                .reg = { "csiphy5" },
                .interrupt = { "csiphy5" },
                .csiphy = {
+                       .id = 5,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1458,6 +1479,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
                .reg = { "csiphy0" },
                .interrupt = { "csiphy0" },
                .csiphy = {
+                       .id = 0,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sc7280
                }
@@ -1472,6 +1494,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
                .reg = { "csiphy1" },
                .interrupt = { "csiphy1" },
                .csiphy = {
+                       .id = 1,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sc7280
                }
@@ -1486,6 +1509,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
                .reg = { "csiphy2" },
                .interrupt = { "csiphy2" },
                .csiphy = {
+                       .id = 2,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sc7280
                }
@@ -1500,6 +1524,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
                .reg = { "csiphy3" },
                .interrupt = { "csiphy3" },
                .csiphy = {
+                       .id = 3,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sc7280
                }
@@ -1514,6 +1539,7 @@ static const struct camss_subdev_resources csiphy_res_7280[] = {
                .reg = { "csiphy4" },
                .interrupt = { "csiphy4" },
                .csiphy = {
+                       .id = 4,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sc7280
                }
@@ -1766,6 +1792,7 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
                .reg = { "csiphy0" },
                .interrupt = { "csiphy0" },
                .csiphy = {
+                       .id = 0,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1779,6 +1806,7 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
                .reg = { "csiphy1" },
                .interrupt = { "csiphy1" },
                .csiphy = {
+                       .id = 1,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1792,6 +1820,7 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
                .reg = { "csiphy2" },
                .interrupt = { "csiphy2" },
                .csiphy = {
+                       .id = 2,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -1805,6 +1834,7 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
                .reg = { "csiphy3" },
                .interrupt = { "csiphy3" },
                .csiphy = {
+                       .id = 3,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -2134,6 +2164,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
                .reg = { "csiphy0" },
                .interrupt = { "csiphy0" },
                .csiphy = {
+                       .id = 0,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -2147,6 +2178,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
                .reg = { "csiphy1" },
                .interrupt = { "csiphy1" },
                .csiphy = {
+                       .id = 1,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -2160,6 +2192,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
                .reg = { "csiphy2" },
                .interrupt = { "csiphy2" },
                .csiphy = {
+                       .id = 2,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -2173,6 +2206,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
                .reg = { "csiphy3" },
                .interrupt = { "csiphy3" },
                .csiphy = {
+                       .id = 3,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -2186,6 +2220,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
                .reg = { "csiphy4" },
                .interrupt = { "csiphy4" },
                .csiphy = {
+                       .id = 4,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -2199,6 +2234,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
                .reg = { "csiphy5" },
                .interrupt = { "csiphy5" },
                .csiphy = {
+                       .id = 5,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -2212,6 +2248,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
                .reg = { "csiphy6" },
                .interrupt = { "csiphy6" },
                .csiphy = {
+                       .id = 6,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -2225,6 +2262,7 @@ static const struct camss_subdev_resources csiphy_res_8550[] = {
                .reg = { "csiphy7" },
                .interrupt = { "csiphy7" },
                .csiphy = {
+                       .id = 7,
                        .hw_ops = &csiphy_ops_3ph_1_0,
                        .formats = &csiphy_formats_sdm845
                }
@@ -2758,7 +2796,8 @@ static int camss_init_subdevices(struct camss *camss)
 
        for (i = 0; i < camss->res->csiphy_num; i++) {
                ret = msm_csiphy_subdev_init(camss, &camss->csiphy[i],
-                                            &res->csiphy_res[i], i);
+                                            &res->csiphy_res[i],
+                                            res->csiphy_res[i].csiphy.id);
                if (ret < 0) {
                        dev_err(camss->dev,
                                "Failed to init csiphy%d sub-device: %d\n",