Lines Matching full:camss

3  * camss.c
30 #include "camss.h"
1618 int camss_pm_domain_on(struct camss *camss, int id) in camss_pm_domain_on() argument
1622 if (id < camss->res->vfe_num) { in camss_pm_domain_on()
1623 struct vfe_device *vfe = &camss->vfe[id]; in camss_pm_domain_on()
1631 void camss_pm_domain_off(struct camss *camss, int id) in camss_pm_domain_off() argument
1633 if (id < camss->res->vfe_num) { in camss_pm_domain_off()
1634 struct vfe_device *vfe = &camss->vfe[id]; in camss_pm_domain_off()
1640 static int vfe_parent_dev_ops_get(struct camss *camss, int id) in vfe_parent_dev_ops_get() argument
1644 if (id < camss->res->vfe_num) { in vfe_parent_dev_ops_get()
1645 struct vfe_device *vfe = &camss->vfe[id]; in vfe_parent_dev_ops_get()
1653 static int vfe_parent_dev_ops_put(struct camss *camss, int id) in vfe_parent_dev_ops_put() argument
1655 if (id < camss->res->vfe_num) { in vfe_parent_dev_ops_put()
1656 struct vfe_device *vfe = &camss->vfe[id]; in vfe_parent_dev_ops_put()
1665 *vfe_parent_dev_ops_get_base_address(struct camss *camss, int id) in vfe_parent_dev_ops_get_base_address() argument
1667 if (id < camss->res->vfe_num) { in vfe_parent_dev_ops_get_base_address()
1668 struct vfe_device *vfe = &camss->vfe[id]; in vfe_parent_dev_ops_get_base_address()
1732 static int camss_of_parse_ports(struct camss *camss) in camss_of_parse_ports() argument
1734 struct device *dev = camss->dev; in camss_of_parse_ports()
1752 csd = v4l2_async_nf_add_fwnode(&camss->notifier, in camss_of_parse_ports()
1777 * @camss: CAMSS device
1781 static int camss_init_subdevices(struct camss *camss) in camss_init_subdevices() argument
1783 const struct camss_resources *res = camss->res; in camss_init_subdevices()
1787 for (i = 0; i < camss->res->csiphy_num; i++) { in camss_init_subdevices()
1788 ret = msm_csiphy_subdev_init(camss, &camss->csiphy[i], in camss_init_subdevices()
1791 dev_err(camss->dev, in camss_init_subdevices()
1799 for (i = 0; i < camss->res->vfe_num; i++) { in camss_init_subdevices()
1800 ret = msm_vfe_subdev_init(camss, &camss->vfe[i], in camss_init_subdevices()
1803 dev_err(camss->dev, in camss_init_subdevices()
1809 for (i = 0; i < camss->res->csid_num; i++) { in camss_init_subdevices()
1810 ret = msm_csid_subdev_init(camss, &camss->csid[i], in camss_init_subdevices()
1813 dev_err(camss->dev, in camss_init_subdevices()
1820 ret = msm_ispif_subdev_init(camss, res->ispif_res); in camss_init_subdevices()
1822 dev_err(camss->dev, "Failed to init ispif sub-device: %d\n", in camss_init_subdevices()
1832 * @camss: CAMSS device
1836 static int camss_link_entities(struct camss *camss) in camss_link_entities() argument
1841 for (i = 0; i < camss->res->csiphy_num; i++) { in camss_link_entities()
1842 for (j = 0; j < camss->res->csid_num; j++) { in camss_link_entities()
1843 ret = media_create_pad_link(&camss->csiphy[i].subdev.entity, in camss_link_entities()
1845 &camss->csid[j].subdev.entity, in camss_link_entities()
1849 dev_err(camss->dev, in camss_link_entities()
1851 camss->csiphy[i].subdev.entity.name, in camss_link_entities()
1852 camss->csid[j].subdev.entity.name, in camss_link_entities()
1859 if (camss->ispif) { in camss_link_entities()
1860 for (i = 0; i < camss->res->csid_num; i++) { in camss_link_entities()
1861 for (j = 0; j < camss->ispif->line_num; j++) { in camss_link_entities()
1862 ret = media_create_pad_link(&camss->csid[i].subdev.entity, in camss_link_entities()
1864 &camss->ispif->line[j].subdev.entity, in camss_link_entities()
1868 dev_err(camss->dev, in camss_link_entities()
1870 camss->csid[i].subdev.entity.name, in camss_link_entities()
1871 camss->ispif->line[j].subdev.entity.name, in camss_link_entities()
1878 for (i = 0; i < camss->ispif->line_num; i++) in camss_link_entities()
1879 for (k = 0; k < camss->res->vfe_num; k++) in camss_link_entities()
1880 for (j = 0; j < camss->vfe[k].res->line_num; j++) { in camss_link_entities()
1881 struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev; in camss_link_entities()
1882 struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev; in camss_link_entities()
1890 dev_err(camss->dev, in camss_link_entities()
1899 for (i = 0; i < camss->res->csid_num; i++) in camss_link_entities()
1900 for (k = 0; k < camss->res->vfe_num; k++) in camss_link_entities()
1901 for (j = 0; j < camss->vfe[k].res->line_num; j++) { in camss_link_entities()
1902 struct v4l2_subdev *csid = &camss->csid[i].subdev; in camss_link_entities()
1903 struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev; in camss_link_entities()
1911 dev_err(camss->dev, in camss_link_entities()
1926 * @camss: CAMSS device
1930 static int camss_register_entities(struct camss *camss) in camss_register_entities() argument
1935 for (i = 0; i < camss->res->csiphy_num; i++) { in camss_register_entities()
1936 ret = msm_csiphy_register_entity(&camss->csiphy[i], in camss_register_entities()
1937 &camss->v4l2_dev); in camss_register_entities()
1939 dev_err(camss->dev, in camss_register_entities()
1946 for (i = 0; i < camss->res->csid_num; i++) { in camss_register_entities()
1947 ret = msm_csid_register_entity(&camss->csid[i], in camss_register_entities()
1948 &camss->v4l2_dev); in camss_register_entities()
1950 dev_err(camss->dev, in camss_register_entities()
1957 ret = msm_ispif_register_entities(camss->ispif, in camss_register_entities()
1958 &camss->v4l2_dev); in camss_register_entities()
1960 dev_err(camss->dev, "Failed to register ispif entities: %d\n", ret); in camss_register_entities()
1964 for (i = 0; i < camss->res->vfe_num; i++) { in camss_register_entities()
1965 ret = msm_vfe_register_entities(&camss->vfe[i], in camss_register_entities()
1966 &camss->v4l2_dev); in camss_register_entities()
1968 dev_err(camss->dev, in camss_register_entities()
1979 msm_vfe_unregister_entities(&camss->vfe[i]); in camss_register_entities()
1982 msm_ispif_unregister_entities(camss->ispif); in camss_register_entities()
1984 i = camss->res->csid_num; in camss_register_entities()
1987 msm_csid_unregister_entity(&camss->csid[i]); in camss_register_entities()
1989 i = camss->res->csiphy_num; in camss_register_entities()
1992 msm_csiphy_unregister_entity(&camss->csiphy[i]); in camss_register_entities()
1999 * @camss: CAMSS device
2003 static void camss_unregister_entities(struct camss *camss) in camss_unregister_entities() argument
2007 for (i = 0; i < camss->res->csiphy_num; i++) in camss_unregister_entities()
2008 msm_csiphy_unregister_entity(&camss->csiphy[i]); in camss_unregister_entities()
2010 for (i = 0; i < camss->res->csid_num; i++) in camss_unregister_entities()
2011 msm_csid_unregister_entity(&camss->csid[i]); in camss_unregister_entities()
2013 msm_ispif_unregister_entities(camss->ispif); in camss_unregister_entities()
2015 for (i = 0; i < camss->res->vfe_num; i++) in camss_unregister_entities()
2016 msm_vfe_unregister_entities(&camss->vfe[i]); in camss_unregister_entities()
2023 struct camss *camss = container_of(async, struct camss, notifier); in camss_subdev_notifier_bound() local
2027 struct csiphy_device *csiphy = &camss->csiphy[id]; in camss_subdev_notifier_bound()
2037 struct camss *camss = container_of(async, struct camss, notifier); in camss_subdev_notifier_complete() local
2038 struct v4l2_device *v4l2_dev = &camss->v4l2_dev; in camss_subdev_notifier_complete()
2055 dev_err(camss->dev, in camss_subdev_notifier_complete()
2064 dev_err(camss->dev, in camss_subdev_notifier_complete()
2072 ret = v4l2_device_register_subdev_nodes(&camss->v4l2_dev); in camss_subdev_notifier_complete()
2076 return media_device_register(&camss->media_dev); in camss_subdev_notifier_complete()
2088 static int camss_configure_pd(struct camss *camss) in camss_configure_pd() argument
2090 const struct camss_resources *res = camss->res; in camss_configure_pd()
2091 struct device *dev = camss->dev; in camss_configure_pd()
2096 camss->genpd_num = of_count_phandle_with_args(dev->of_node, in camss_configure_pd()
2099 if (camss->genpd_num < 0) { in camss_configure_pd()
2100 dev_err(dev, "Power domains are not defined for camss\n"); in camss_configure_pd()
2101 return camss->genpd_num; in camss_configure_pd()
2107 * option to attach it again, this is the case for CAMSS on MSM8916. in camss_configure_pd()
2109 if (camss->genpd_num == 1) in camss_configure_pd()
2113 for (vfepd_num = i = 0; i < camss->res->vfe_num; i++) { in camss_configure_pd()
2120 * then the additional power-domain is for the entire CAMSS block. in camss_configure_pd()
2122 if (!(camss->genpd_num > vfepd_num)) in camss_configure_pd()
2130 if (camss->res->pd_name) { in camss_configure_pd()
2131 camss->genpd = dev_pm_domain_attach_by_name(camss->dev, in camss_configure_pd()
2132 camss->res->pd_name); in camss_configure_pd()
2133 if (IS_ERR(camss->genpd)) { in camss_configure_pd()
2134 ret = PTR_ERR(camss->genpd); in camss_configure_pd()
2139 if (!camss->genpd) { in camss_configure_pd()
2144 camss->genpd = dev_pm_domain_attach_by_id(camss->dev, in camss_configure_pd()
2145 camss->genpd_num - 1); in camss_configure_pd()
2147 if (IS_ERR_OR_NULL(camss->genpd)) { in camss_configure_pd()
2148 if (!camss->genpd) in camss_configure_pd()
2151 ret = PTR_ERR(camss->genpd); in camss_configure_pd()
2154 camss->genpd_link = device_link_add(camss->dev, camss->genpd, in camss_configure_pd()
2157 if (!camss->genpd_link) { in camss_configure_pd()
2165 dev_pm_domain_detach(camss->genpd, true); in camss_configure_pd()
2170 static int camss_icc_get(struct camss *camss) in camss_icc_get() argument
2175 icc_res = camss->res->icc_res; in camss_icc_get()
2177 for (i = 0; i < camss->res->icc_path_num; i++) { in camss_icc_get()
2178 camss->icc_path[i] = devm_of_icc_get(camss->dev, in camss_icc_get()
2180 if (IS_ERR(camss->icc_path[i])) in camss_icc_get()
2181 return PTR_ERR(camss->icc_path[i]); in camss_icc_get()
2187 static void camss_genpd_subdevice_cleanup(struct camss *camss) in camss_genpd_subdevice_cleanup() argument
2191 for (i = 0; i < camss->res->vfe_num; i++) in camss_genpd_subdevice_cleanup()
2192 msm_vfe_genpd_cleanup(&camss->vfe[i]); in camss_genpd_subdevice_cleanup()
2195 static void camss_genpd_cleanup(struct camss *camss) in camss_genpd_cleanup() argument
2197 if (camss->genpd_num == 1) in camss_genpd_cleanup()
2200 camss_genpd_subdevice_cleanup(camss); in camss_genpd_cleanup()
2202 if (camss->genpd_link) in camss_genpd_cleanup()
2203 device_link_del(camss->genpd_link); in camss_genpd_cleanup()
2205 dev_pm_domain_detach(camss->genpd, true); in camss_genpd_cleanup()
2209 * camss_probe - Probe CAMSS platform device
2210 * @pdev: Pointer to CAMSS platform device
2217 struct camss *camss; in camss_probe() local
2221 camss = devm_kzalloc(dev, sizeof(*camss), GFP_KERNEL); in camss_probe()
2222 if (!camss) in camss_probe()
2225 camss->res = of_device_get_match_data(dev); in camss_probe()
2227 atomic_set(&camss->ref_count, 0); in camss_probe()
2228 camss->dev = dev; in camss_probe()
2229 platform_set_drvdata(pdev, camss); in camss_probe()
2231 camss->csiphy = devm_kcalloc(dev, camss->res->csiphy_num, in camss_probe()
2232 sizeof(*camss->csiphy), GFP_KERNEL); in camss_probe()
2233 if (!camss->csiphy) in camss_probe()
2236 camss->csid = devm_kcalloc(dev, camss->res->csid_num, sizeof(*camss->csid), in camss_probe()
2238 if (!camss->csid) in camss_probe()
2241 if (camss->res->version == CAMSS_8x16 || in camss_probe()
2242 camss->res->version == CAMSS_8x96) { in camss_probe()
2243 camss->ispif = devm_kcalloc(dev, 1, sizeof(*camss->ispif), GFP_KERNEL); in camss_probe()
2244 if (!camss->ispif) in camss_probe()
2248 camss->vfe = devm_kcalloc(dev, camss->res->vfe_num, in camss_probe()
2249 sizeof(*camss->vfe), GFP_KERNEL); in camss_probe()
2250 if (!camss->vfe) in camss_probe()
2253 ret = camss_icc_get(camss); in camss_probe()
2257 ret = camss_configure_pd(camss); in camss_probe()
2263 ret = camss_init_subdevices(camss); in camss_probe()
2271 camss->media_dev.dev = camss->dev; in camss_probe()
2272 strscpy(camss->media_dev.model, "Qualcomm Camera Subsystem", in camss_probe()
2273 sizeof(camss->media_dev.model)); in camss_probe()
2274 camss->media_dev.ops = &camss_media_ops; in camss_probe()
2275 media_device_init(&camss->media_dev); in camss_probe()
2277 camss->v4l2_dev.mdev = &camss->media_dev; in camss_probe()
2278 ret = v4l2_device_register(camss->dev, &camss->v4l2_dev); in camss_probe()
2284 v4l2_async_nf_init(&camss->notifier, &camss->v4l2_dev); in camss_probe()
2288 num_subdevs = camss_of_parse_ports(camss); in camss_probe()
2294 ret = camss_register_entities(camss); in camss_probe()
2298 ret = camss->res->link_entities(camss); in camss_probe()
2303 camss->notifier.ops = &camss_subdev_notifier_ops; in camss_probe()
2305 ret = v4l2_async_nf_register(&camss->notifier); in camss_probe()
2313 ret = v4l2_device_register_subdev_nodes(&camss->v4l2_dev); in camss_probe()
2320 ret = media_device_register(&camss->media_dev); in camss_probe()
2331 camss_unregister_entities(camss); in camss_probe()
2333 v4l2_device_unregister(&camss->v4l2_dev); in camss_probe()
2334 v4l2_async_nf_cleanup(&camss->notifier); in camss_probe()
2337 camss_genpd_cleanup(camss); in camss_probe()
2342 void camss_delete(struct camss *camss) in camss_delete() argument
2344 v4l2_device_unregister(&camss->v4l2_dev); in camss_delete()
2345 media_device_unregister(&camss->media_dev); in camss_delete()
2346 media_device_cleanup(&camss->media_dev); in camss_delete()
2348 pm_runtime_disable(camss->dev); in camss_delete()
2352 * camss_remove - Remove CAMSS platform device
2353 * @pdev: Pointer to CAMSS platform device
2359 struct camss *camss = platform_get_drvdata(pdev); in camss_remove() local
2361 v4l2_async_nf_unregister(&camss->notifier); in camss_remove()
2362 v4l2_async_nf_cleanup(&camss->notifier); in camss_remove()
2363 camss_unregister_entities(camss); in camss_remove()
2365 if (atomic_read(&camss->ref_count) == 0) in camss_remove()
2366 camss_delete(camss); in camss_remove()
2368 camss_genpd_cleanup(camss); in camss_remove()
2448 { .compatible = "qcom,msm8916-camss", .data = &msm8916_resources },
2449 { .compatible = "qcom,msm8996-camss", .data = &msm8996_resources },
2450 { .compatible = "qcom,sdm660-camss", .data = &sdm660_resources },
2451 { .compatible = "qcom,sdm845-camss", .data = &sdm845_resources },
2452 { .compatible = "qcom,sm8250-camss", .data = &sm8250_resources },
2453 { .compatible = "qcom,sc8280xp-camss", .data = &sc8280xp_resources },
2461 struct camss *camss = dev_get_drvdata(dev); in camss_runtime_suspend() local
2465 for (i = 0; i < camss->res->icc_path_num; i++) { in camss_runtime_suspend()
2466 ret = icc_set_bw(camss->icc_path[i], 0, 0); in camss_runtime_suspend()
2476 struct camss *camss = dev_get_drvdata(dev); in camss_runtime_resume() local
2477 const struct resources_icc *icc_res = camss->res->icc_res; in camss_runtime_resume()
2481 for (i = 0; i < camss->res->icc_path_num; i++) { in camss_runtime_resume()
2482 ret = icc_set_bw(camss->icc_path[i], in camss_runtime_resume()
2502 .name = "qcom-camss",
2510 MODULE_ALIAS("platform:qcom-camss");