Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: qcom: camss: Decouple VFE from CSID

Decouple the direct calls to VFE's vfe_get/put in the CSID subdev
in order to prepare for the introduction of IFE subdev.

Also decouple CSID base address from VFE since on the Titan platform
CSID register base address resides within VFE's base address.

Signed-off-by: Milen Mitkov <quic_mmitkov@quicinc.com>
Signed-off-by: Gjorgji Rosikopulos <quic_grosikop@quicinc.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp/sm8250/sdm845/apq8016
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Milen Mitkov and committed by
Hans Verkuil
b1e6eef5 73ac545c

+89 -5
+11 -5
drivers/media/platform/qcom/camss/camss-csid.c
··· 602 602 struct csid_device *csid = v4l2_get_subdevdata(sd); 603 603 struct camss *camss = csid->camss; 604 604 struct device *dev = camss->dev; 605 - struct vfe_device *vfe = &camss->vfe[csid->id]; 606 605 int ret = 0; 607 606 608 607 if (on) { ··· 610 611 * switching on the CSID. Do so unconditionally, as there is no 611 612 * drawback in following the same powering order on older SoCs. 612 613 */ 613 - ret = vfe_get(vfe); 614 + ret = csid->res->parent_dev_ops->get(camss, csid->id); 614 615 if (ret < 0) 615 616 return ret; 616 617 ··· 662 663 regulator_bulk_disable(csid->num_supplies, 663 664 csid->supplies); 664 665 pm_runtime_put_sync(dev); 665 - vfe_put(vfe); 666 + csid->res->parent_dev_ops->put(camss, csid->id); 666 667 } 667 668 668 669 return ret; ··· 1020 1021 csid->id = id; 1021 1022 csid->res = &res->csid; 1022 1023 1024 + if (dev_WARN_ONCE(dev, !csid->res->parent_dev_ops, 1025 + "Error: CSID depends on VFE/IFE device ops!\n")) { 1026 + return -EINVAL; 1027 + } 1028 + 1023 1029 csid->res->hw_ops->subdev_init(csid); 1024 1030 1025 1031 /* Memory */ ··· 1035 1031 * VFE to be initialized before CSID 1036 1032 */ 1037 1033 if (id >= 2) /* VFE/CSID lite */ 1038 - csid->base = camss->vfe[id].base + VFE_480_LITE_CSID_OFFSET; 1034 + csid->base = csid->res->parent_dev_ops->get_base_address(camss, id) 1035 + + VFE_480_LITE_CSID_OFFSET; 1039 1036 else 1040 - csid->base = camss->vfe[id].base + VFE_480_CSID_OFFSET; 1037 + csid->base = csid->res->parent_dev_ops->get_base_address(camss, id) 1038 + + VFE_480_CSID_OFFSET; 1041 1039 } else { 1042 1040 csid->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]); 1043 1041 if (IS_ERR(csid->base))
+1
drivers/media/platform/qcom/camss/camss-csid.h
··· 157 157 struct csid_subdev_resources { 158 158 bool is_lite; 159 159 const struct csid_hw_ops *hw_ops; 160 + const struct parent_dev_ops *parent_dev_ops; 160 161 const struct csid_formats *formats; 161 162 }; 162 163
+69
drivers/media/platform/qcom/camss/camss.c
··· 32 32 #define CAMSS_CLOCK_MARGIN_NUMERATOR 105 33 33 #define CAMSS_CLOCK_MARGIN_DENOMINATOR 100 34 34 35 + static const struct parent_dev_ops vfe_parent_dev_ops; 36 + 35 37 static const struct camss_subdev_resources csiphy_res_8x16[] = { 36 38 /* CSIPHY0 */ 37 39 { ··· 86 84 .interrupt = { "csid0" }, 87 85 .csid = { 88 86 .hw_ops = &csid_ops_4_1, 87 + .parent_dev_ops = &vfe_parent_dev_ops, 89 88 .formats = &csid_formats_4_1 90 89 } 91 90 }, ··· 108 105 .interrupt = { "csid1" }, 109 106 .csid = { 110 107 .hw_ops = &csid_ops_4_1, 108 + .parent_dev_ops = &vfe_parent_dev_ops, 111 109 .formats = &csid_formats_4_1 112 110 } 113 111 }, ··· 220 216 .interrupt = { "csid0" }, 221 217 .csid = { 222 218 .hw_ops = &csid_ops_4_7, 219 + .parent_dev_ops = &vfe_parent_dev_ops, 223 220 .formats = &csid_formats_4_7 224 221 } 225 222 }, ··· 242 237 .interrupt = { "csid1" }, 243 238 .csid = { 244 239 .hw_ops = &csid_ops_4_7, 240 + .parent_dev_ops = &vfe_parent_dev_ops, 245 241 .formats = &csid_formats_4_7 246 242 } 247 243 }, ··· 264 258 .interrupt = { "csid2" }, 265 259 .csid = { 266 260 .hw_ops = &csid_ops_4_7, 261 + .parent_dev_ops = &vfe_parent_dev_ops, 267 262 .formats = &csid_formats_4_7 268 263 } 269 264 }, ··· 286 279 .interrupt = { "csid3" }, 287 280 .csid = { 288 281 .hw_ops = &csid_ops_4_7, 282 + .parent_dev_ops = &vfe_parent_dev_ops, 289 283 .formats = &csid_formats_4_7 290 284 } 291 285 } ··· 433 425 .interrupt = { "csid0" }, 434 426 .csid = { 435 427 .hw_ops = &csid_ops_4_7, 428 + .parent_dev_ops = &vfe_parent_dev_ops, 436 429 .formats = &csid_formats_4_7 437 430 } 438 431 }, ··· 458 449 .interrupt = { "csid1" }, 459 450 .csid = { 460 451 .hw_ops = &csid_ops_4_7, 452 + .parent_dev_ops = &vfe_parent_dev_ops, 461 453 .formats = &csid_formats_4_7 462 454 } 463 455 }, ··· 483 473 .interrupt = { "csid2" }, 484 474 .csid = { 485 475 .hw_ops = &csid_ops_4_7, 476 + .parent_dev_ops = &vfe_parent_dev_ops, 486 477 .formats = &csid_formats_4_7 487 478 } 488 479 }, ··· 508 497 .interrupt = { "csid3" }, 509 498 .csid = { 510 499 .hw_ops = &csid_ops_4_7, 500 + .parent_dev_ops = &vfe_parent_dev_ops, 511 501 .formats = &csid_formats_4_7 512 502 } 513 503 } ··· 695 683 .interrupt = { "csid0" }, 696 684 .csid = { 697 685 .hw_ops = &csid_ops_gen2, 686 + .parent_dev_ops = &vfe_parent_dev_ops, 698 687 .formats = &csid_formats_gen2 699 688 } 700 689 }, ··· 720 707 .interrupt = { "csid1" }, 721 708 .csid = { 722 709 .hw_ops = &csid_ops_gen2, 710 + .parent_dev_ops = &vfe_parent_dev_ops, 723 711 .formats = &csid_formats_gen2 724 712 } 725 713 }, ··· 746 732 .csid = { 747 733 .is_lite = true, 748 734 .hw_ops = &csid_ops_gen2, 735 + .parent_dev_ops = &vfe_parent_dev_ops, 749 736 .formats = &csid_formats_gen2 750 737 } 751 738 } ··· 929 914 .interrupt = { "csid0" }, 930 915 .csid = { 931 916 .hw_ops = &csid_ops_gen2, 917 + .parent_dev_ops = &vfe_parent_dev_ops, 932 918 .formats = &csid_formats_gen2 933 919 } 934 920 }, ··· 946 930 .interrupt = { "csid1" }, 947 931 .csid = { 948 932 .hw_ops = &csid_ops_gen2, 933 + .parent_dev_ops = &vfe_parent_dev_ops, 949 934 .formats = &csid_formats_gen2 950 935 } 951 936 }, ··· 963 946 .csid = { 964 947 .is_lite = true, 965 948 .hw_ops = &csid_ops_gen2, 949 + .parent_dev_ops = &vfe_parent_dev_ops, 966 950 .formats = &csid_formats_gen2 967 951 } 968 952 }, ··· 980 962 .csid = { 981 963 .is_lite = true, 982 964 .hw_ops = &csid_ops_gen2, 965 + .parent_dev_ops = &vfe_parent_dev_ops, 983 966 .formats = &csid_formats_gen2 984 967 } 985 968 } ··· 1180 1161 .interrupt = { "csid0" }, 1181 1162 .csid = { 1182 1163 .hw_ops = &csid_ops_gen2, 1164 + .parent_dev_ops = &vfe_parent_dev_ops, 1183 1165 .formats = &csid_formats_gen2 1184 1166 } 1185 1167 }, ··· 1196 1176 .interrupt = { "csid1" }, 1197 1177 .csid = { 1198 1178 .hw_ops = &csid_ops_gen2, 1179 + .parent_dev_ops = &vfe_parent_dev_ops, 1199 1180 .formats = &csid_formats_gen2 1200 1181 } 1201 1182 }, ··· 1212 1191 .interrupt = { "csid2" }, 1213 1192 .csid = { 1214 1193 .hw_ops = &csid_ops_gen2, 1194 + .parent_dev_ops = &vfe_parent_dev_ops, 1215 1195 .formats = &csid_formats_gen2 1216 1196 } 1217 1197 }, ··· 1228 1206 .interrupt = { "csid3" }, 1229 1207 .csid = { 1230 1208 .hw_ops = &csid_ops_gen2, 1209 + .parent_dev_ops = &vfe_parent_dev_ops, 1231 1210 .formats = &csid_formats_gen2 1232 1211 } 1233 1212 }, ··· 1244 1221 .csid = { 1245 1222 .is_lite = true, 1246 1223 .hw_ops = &csid_ops_gen2, 1224 + .parent_dev_ops = &vfe_parent_dev_ops, 1247 1225 .formats = &csid_formats_gen2 1248 1226 } 1249 1227 }, ··· 1260 1236 .csid = { 1261 1237 .is_lite = true, 1262 1238 .hw_ops = &csid_ops_gen2, 1239 + .parent_dev_ops = &vfe_parent_dev_ops, 1263 1240 .formats = &csid_formats_gen2 1264 1241 } 1265 1242 }, ··· 1276 1251 .csid = { 1277 1252 .is_lite = true, 1278 1253 .hw_ops = &csid_ops_gen2, 1254 + .parent_dev_ops = &vfe_parent_dev_ops, 1279 1255 .formats = &csid_formats_gen2 1280 1256 } 1281 1257 }, ··· 1292 1266 .csid = { 1293 1267 .is_lite = true, 1294 1268 .hw_ops = &csid_ops_gen2, 1269 + .parent_dev_ops = &vfe_parent_dev_ops, 1295 1270 .formats = &csid_formats_gen2 1296 1271 } 1297 1272 } ··· 1636 1609 vfe->res->hw_ops->pm_domain_off(vfe); 1637 1610 } 1638 1611 } 1612 + 1613 + static int vfe_parent_dev_ops_get(struct camss *camss, int id) 1614 + { 1615 + int ret = -EINVAL; 1616 + 1617 + if (id < camss->res->vfe_num) { 1618 + struct vfe_device *vfe = &camss->vfe[id]; 1619 + 1620 + ret = vfe_get(vfe); 1621 + } 1622 + 1623 + return ret; 1624 + } 1625 + 1626 + static int vfe_parent_dev_ops_put(struct camss *camss, int id) 1627 + { 1628 + if (id < camss->res->vfe_num) { 1629 + struct vfe_device *vfe = &camss->vfe[id]; 1630 + 1631 + vfe_put(vfe); 1632 + } 1633 + 1634 + return 0; 1635 + } 1636 + 1637 + static void __iomem 1638 + *vfe_parent_dev_ops_get_base_address(struct camss *camss, int id) 1639 + { 1640 + if (id < camss->res->vfe_num) { 1641 + struct vfe_device *vfe = &camss->vfe[id]; 1642 + 1643 + return vfe->base; 1644 + } 1645 + 1646 + return NULL; 1647 + } 1648 + 1649 + static const struct parent_dev_ops vfe_parent_dev_ops = { 1650 + .get = vfe_parent_dev_ops_get, 1651 + .put = vfe_parent_dev_ops_put, 1652 + .get_base_address = vfe_parent_dev_ops_get_base_address 1653 + }; 1639 1654 1640 1655 /* 1641 1656 * camss_of_parse_endpoint_node - Parse port endpoint node
+8
drivers/media/platform/qcom/camss/camss.h
··· 135 135 u32 nfreqs; 136 136 }; 137 137 138 + struct parent_dev_ops { 139 + int (*get)(struct camss *camss, int id); 140 + int (*put)(struct camss *camss, int id); 141 + void __iomem *(*get_base_address)(struct camss *camss, int id); 142 + }; 143 + 138 144 void camss_add_clock_margin(u64 *rate); 139 145 int camss_enable_clocks(int nclocks, struct camss_clock *clock, 140 146 struct device *dev); ··· 151 145 int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock); 152 146 int camss_pm_domain_on(struct camss *camss, int id); 153 147 void camss_pm_domain_off(struct camss *camss, int id); 148 + int camss_vfe_get(struct camss *camss, int id); 149 + void camss_vfe_put(struct camss *camss, int id); 154 150 void camss_delete(struct camss *camss); 155 151 156 152 #endif /* QC_MSM_CAMSS_H */