Lines Matching +full:csi +full:- +full:pclk

1 // SPDX-License-Identifier: GPL-2.0-only
6 * formerly was located in v4l2-of.c.
11 * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
27 #include <media/v4l2-async.h>
28 #include <media/v4l2-fwnode.h>
29 #include <media/v4l2-subdev.h>
31 #include "v4l2-subdev-priv.h"
45 "MIPI CSI-2 C-PHY",
49 "MIPI CSI-1",
57 "MIPI CSI-2 D-PHY",
91 return conv ? conv->mbus_type : V4L2_MBUS_INVALID;
100 return conv ? conv->name : "not found";
121 return conv ? conv->name : "not found";
128 struct v4l2_mbus_config_mipi_csi2 *bus = &vep->bus.mipi_csi2;
144 num_data_lanes = min_t(u32, bus->num_data_lanes,
147 clock_lane = bus->clock_lane;
152 array[i] = bus->data_lanes[i];
161 rval = fwnode_property_count_u32(fwnode, "data-lanes");
166 fwnode_property_read_u32_array(fwnode, "data-lanes", array,
171 pr_debug("data-lanes property exists; disabling default mapping\n");
179 pr_warn("duplicated lane %u in data-lanes, using defaults\n",
189 rval = fwnode_property_count_u32(fwnode, "lane-polarities");
192 pr_warn("invalid number of lane-polarities entries (need %u, got %u)\n",
194 return -EINVAL;
200 rval = fwnode_property_count_u32(fwnode, "line-orders");
203 pr_warn("invalid number of line-orders entries (need %u, got %u)\n",
205 return -EINVAL;
211 if (!fwnode_property_read_u32(fwnode, "clock-lanes", &v)) {
219 pr_warn("duplicated lane %u in clock-lanes, using defaults\n",
224 if (fwnode_property_present(fwnode, "clock-noncontinuous")) {
226 pr_debug("non-continuous clock\n");
232 /* Only D-PHY has a clock lane. */
236 bus->flags = flags;
238 vep->bus_type = V4L2_MBUS_CSI2_DPHY;
239 bus->num_data_lanes = num_data_lanes;
242 bus->clock_lane = 0;
244 bus->data_lanes[i] = dfl_data_lane_index + i;
246 bus->clock_lane = clock_lane;
248 bus->data_lanes[i] = array[i];
253 "lane-polarities", array,
257 bus->lane_polarities[i] = array[i];
267 "line-orders", array,
276 pr_warn("lane %u invalid line-order assuming ABC (got %u)\n",
278 bus->line_orders[i] =
283 bus->line_orders[i] = array[i];
289 bus->line_orders[i] =
311 struct v4l2_mbus_config_parallel *bus = &vep->bus.parallel;
316 flags = bus->flags;
318 if (!fwnode_property_read_u32(fwnode, "hsync-active", &v)) {
323 pr_debug("hsync-active %s\n", v ? "high" : "low");
326 if (!fwnode_property_read_u32(fwnode, "vsync-active", &v)) {
331 pr_debug("vsync-active %s\n", v ? "high" : "low");
334 if (!fwnode_property_read_u32(fwnode, "field-even-active", &v)) {
339 pr_debug("field-even-active %s\n", v ? "high" : "low");
342 if (!fwnode_property_read_u32(fwnode, "pclk-sample", &v)) {
349 pr_debug("pclk-sample low\n");
353 pr_debug("pclk-sample high\n");
357 pr_debug("pclk-sample dual edge\n");
360 pr_warn("invalid argument for pclk-sample");
365 if (!fwnode_property_read_u32(fwnode, "data-active", &v)) {
370 pr_debug("data-active %s\n", v ? "high" : "low");
373 if (fwnode_property_present(fwnode, "slave-mode")) {
382 if (!fwnode_property_read_u32(fwnode, "bus-width", &v)) {
383 bus->bus_width = v;
384 pr_debug("bus-width %u\n", v);
387 if (!fwnode_property_read_u32(fwnode, "data-shift", &v)) {
388 bus->data_shift = v;
389 pr_debug("data-shift %u\n", v);
392 if (!fwnode_property_read_u32(fwnode, "sync-on-green-active", &v)) {
397 pr_debug("sync-on-green-active %s\n", v ? "high" : "low");
400 if (!fwnode_property_read_u32(fwnode, "data-enable-active", &v)) {
405 pr_debug("data-enable-active %s\n", v ? "high" : "low");
410 bus->flags = flags;
412 vep->bus_type = V4L2_MBUS_PARALLEL;
414 vep->bus_type = V4L2_MBUS_BT656;
417 vep->bus_type = V4L2_MBUS_PARALLEL;
418 bus->flags = flags;
421 vep->bus_type = V4L2_MBUS_BT656;
422 bus->flags = flags & ~PARALLEL_MBUS_FLAGS;
432 struct v4l2_mbus_config_mipi_csi1 *bus = &vep->bus.mipi_csi1;
435 if (!fwnode_property_read_u32(fwnode, "clock-inv", &v)) {
436 bus->clock_inv = v;
437 pr_debug("clock-inv %u\n", v);
441 bus->strobe = v;
445 if (!fwnode_property_read_u32(fwnode, "data-lanes", &v)) {
446 bus->data_lane = v;
447 pr_debug("data-lanes %u\n", v);
450 if (!fwnode_property_read_u32(fwnode, "clock-lanes", &v)) {
451 bus->clock_lane = v;
452 pr_debug("clock-lanes %u\n", v);
456 vep->bus_type = V4L2_MBUS_CCP2;
458 vep->bus_type = V4L2_MBUS_CSI1;
470 fwnode_property_read_u32(fwnode, "bus-type", &bus_type);
473 v4l2_fwnode_mbus_type_to_string(vep->bus_type),
474 vep->bus_type);
478 return -EINVAL;
481 if (vep->bus_type != V4L2_MBUS_UNKNOWN) {
483 vep->bus_type != mbus_type) {
485 v4l2_fwnode_mbus_type_to_string(vep->bus_type));
486 return -ENXIO;
489 vep->bus_type = mbus_type;
492 switch (vep->bus_type) {
499 if (vep->bus_type == V4L2_MBUS_UNKNOWN)
504 v4l2_fwnode_mbus_type_to_string(vep->bus_type),
505 vep->bus_type);
510 v4l2_fwnode_endpoint_parse_csi1_bus(fwnode, vep, vep->bus_type);
516 vep->bus_type);
524 vep->bus_type);
529 return -EINVAL;
532 fwnode_graph_parse_endpoint(fwnode, &vep->base);
555 kfree(vep->link_frequencies);
556 vep->link_frequencies = NULL;
569 rval = fwnode_property_count_u64(fwnode, "link-frequencies");
573 vep->link_frequencies =
574 kmalloc_array(rval, sizeof(*vep->link_frequencies),
576 if (!vep->link_frequencies)
577 return -ENOMEM;
579 vep->nr_of_link_frequencies = rval;
582 "link-frequencies",
583 vep->link_frequencies,
584 vep->nr_of_link_frequencies);
590 for (i = 0; i < vep->nr_of_link_frequencies; i++)
591 pr_debug("link-frequencies %u value %llu\n", i,
592 vep->link_frequencies[i]);
609 link->local_id = fwep.id;
610 link->local_port = fwep.port;
611 link->local_node = fwnode_graph_get_port_parent(fwnode);
612 if (!link->local_node)
613 return -ENOLINK;
620 link->remote_id = fwep.id;
621 link->remote_port = fwep.port;
622 link->remote_node = fwnode_graph_get_port_parent(fwnode);
623 if (!link->remote_node)
632 fwnode_handle_put(link->local_node);
634 return -ENOLINK;
640 fwnode_handle_put(link->local_node);
641 fwnode_handle_put(link->remote_node);
651 .compatible = "composite-video-connector",
654 .compatible = "svideo-connector",
677 ret = fwnode_property_read_u32(fwnode, "sdtv-standards", &stds);
680 vc->connector.analog.sdtv_stds = ret ? V4L2_STD_ALL : stds;
687 if (IS_ERR_OR_NULL(connector) || connector->type == V4L2_CONN_UNKNOWN)
690 list_for_each_entry_safe(link, tmp, &connector->links, head) {
691 v4l2_fwnode_put_link(&link->fwnode_link);
692 list_del(&link->head);
696 kfree(connector->label);
697 connector->label = NULL;
698 connector->type = V4L2_CONN_UNKNOWN;
711 /* The connector-type is stored within the compatible string. */
728 return -EINVAL;
732 INIT_LIST_HEAD(&connector->links);
744 err = -ENOTCONN;
748 connector->type = connector_type;
749 connector->name = fwnode_get_name(connector_node);
751 connector->label = err ? NULL : kstrdup_const(label, GFP_KERNEL);
754 switch (connector->type) {
778 if (!fwnode || !connector || connector->type == V4L2_CONN_UNKNOWN)
779 return -EINVAL;
783 return -ENOTCONN;
787 err = -ENOMEM;
791 err = v4l2_fwnode_parse_link(connector_ep, &link->fwnode_link);
797 list_add(&link->head, &connector->links);
798 connector->nr_of_links++;
819 props->orientation = V4L2_FWNODE_PROPERTY_UNSET;
829 return -EINVAL;
832 props->orientation = val;
836 props->rotation = V4L2_FWNODE_PROPERTY_UNSET;
841 return -EINVAL;
844 props->rotation = val;
853 * v4l2_fwnode_reference_parse - parse references for async sub-devices
859 * -ENOENT if no entries were found
860 * -ENOMEM if memory allocation failed
861 * -EINVAL if property parsing failed
882 if (PTR_ERR(asd) == -EEXIST)
889 /* -ENOENT here means successful parsing */
890 if (ret != -ENOENT)
893 /* Return -ENOENT if no references were found */
894 return index ? 0 : -ENOENT;
898 * v4l2_fwnode_reference_get_int_prop - parse a reference with integer
928 * Documentation/firmware-guide/acpi/dsd/ instead and especially graph.txt,
929 * data-node-references.txt and leds.txt .
936 * ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
943 * ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
949 * ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
953 * ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
959 * ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
963 * "remote-endpoint",
978 * ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
985 * ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
989 * ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
996 * ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
1000 * "remote-endpoint",
1015 * @prop: "remote-endpoint"
1034 * remote-endpoint = <&isp 4 0>;
1045 * remote-endpoint = <&cam 0 0>;
1052 * -ENOENT if no entries (or the property itself) were found
1053 * -EINVAL if property parsing otherwise failed
1054 * -ENOMEM if memory allocation failed
1071 * Note that right now both -ENODATA and -ENOENT may signal
1072 * out-of-bounds access. Return -ENOENT in that case.
1077 return ERR_PTR(ret == -ENODATA ? -ENOENT : ret);
1084 while (nprops--) {
1101 fwnode = ERR_PTR(-ENOENT);
1120 * v4l2_fwnode_reference_parse_int_props - parse references for async
1121 * sub-devices
1130 * @props. Then, set up V4L2 async sub-devices for those fwnodes in the notifier
1138 * -ENOENT if no entries (or the property itself) were found
1139 * -EINVAL if property parsing otherwisefailed
1140 * -ENOMEM if memory allocation failed
1150 const char *prop = p->name;
1151 const char * const *props = p->props;
1152 unsigned int nprops = p->nprops;
1161 * Note that right now both -ENODATA and -ENOENT may
1162 * signal out-of-bounds access. Return the error in
1165 if (PTR_ERR(fwnode) != -ENOENT &&
1166 PTR_ERR(fwnode) != -ENODATA)
1188 if (ret == -EEXIST)
1195 return !fwnode || PTR_ERR(fwnode) == -ENOENT ? 0 : PTR_ERR(fwnode);
1199 * v4l2_async_nf_parse_fwnode_sensor - parse common references on
1200 * sensors for async sub-devices
1205 * sensor and set up async sub-devices for them.
1209 * sub-devices are no longer in use, even in the case the function returned an
1213 * -ENOMEM if memory allocation failed
1214 * -EINVAL if property parsing failed
1222 { "flash-leds", led_props, ARRAY_SIZE(led_props) },
1223 { "mipi-img-flash-leds", },
1224 { "lens-focus", },
1225 { "mipi-img-lens-focus", },
1239 if (ret && ret != -ENOENT) {
1254 if (WARN_ON(!sd->dev))
1255 return -ENODEV;
1259 return -ENOMEM;
1267 ret = v4l2_async_nf_parse_fwnode_sensor(sd->dev, notifier);
1279 sd->subdev_notifier = notifier;