Lines Matching full:mdev
81 static struct media_entity *find_entity(struct media_device *mdev, u32 id) in find_entity() argument
88 media_device_for_each_entity(entity, mdev) { in find_entity()
98 static long media_device_enum_entities(struct media_device *mdev, void *arg) in media_device_enum_entities() argument
103 ent = find_entity(mdev, entd->id); in media_device_enum_entities()
151 static long media_device_enum_links(struct media_device *mdev, void *arg) in media_device_enum_links() argument
156 entity = find_entity(mdev, links->entity); in media_device_enum_links()
200 static long media_device_setup_link(struct media_device *mdev, void *arg) in media_device_setup_link() argument
209 source = find_entity(mdev, linkd->source.entity); in media_device_setup_link()
210 sink = find_entity(mdev, linkd->sink.entity); in media_device_setup_link()
230 static long media_device_get_topology(struct media_device *mdev, void *arg) in media_device_get_topology() argument
244 topo->topology_version = mdev->topology_version; in media_device_get_topology()
249 media_device_for_each_entity(entity, mdev) { in media_device_get_topology()
277 media_device_for_each_intf(intf, mdev) { in media_device_get_topology()
313 media_device_for_each_pad(pad, mdev) { in media_device_get_topology()
341 media_device_for_each_link(link, mdev) { in media_device_get_topology()
373 static long media_device_request_alloc(struct media_device *mdev, void *arg) in media_device_request_alloc() argument
377 if (!mdev->ops || !mdev->ops->req_validate || !mdev->ops->req_queue) in media_device_request_alloc()
380 return media_request_alloc(mdev, alloc_fd); in media_device_request_alloc()
489 static long media_device_enum_links32(struct media_device *mdev, in media_device_enum_links32() argument
506 ret = media_device_enum_links(mdev, &links); in media_device_enum_links32()
559 struct media_device *mdev = devnode->media_dev; in model_show() local
561 return sprintf(buf, "%.*s\n", (int)sizeof(mdev->model), mdev->model); in model_show()
577 struct media_device *mdev = entity->graph_obj.mdev; in __media_device_unregister_entity() local
582 ida_free(&mdev->entity_internal_idx, entity->internal_idx); in __media_device_unregister_entity()
585 list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { in __media_device_unregister_entity()
605 int __must_check media_device_register_entity(struct media_device *mdev, in media_device_register_entity() argument
614 dev_warn(mdev->dev, in media_device_register_entity()
619 WARN_ON(entity->graph_obj.mdev != NULL); in media_device_register_entity()
620 entity->graph_obj.mdev = mdev; in media_device_register_entity()
625 ret = ida_alloc_min(&mdev->entity_internal_idx, 1, GFP_KERNEL); in media_device_register_entity()
630 mutex_lock(&mdev->graph_mutex); in media_device_register_entity()
631 mdev->entity_internal_idx_max = in media_device_register_entity()
632 max(mdev->entity_internal_idx_max, entity->internal_idx); in media_device_register_entity()
635 media_gobj_create(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); in media_device_register_entity()
639 media_gobj_create(mdev, MEDIA_GRAPH_PAD, &iter->graph_obj); in media_device_register_entity()
642 list_for_each_entry_safe(notify, next, &mdev->entity_notify, list) in media_device_register_entity()
645 if (mdev->entity_internal_idx_max in media_device_register_entity()
646 >= mdev->pm_count_walk.ent_enum.idx_max) { in media_device_register_entity()
654 ret = media_graph_walk_init(&new, mdev); in media_device_register_entity()
657 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity()
660 media_graph_walk_cleanup(&mdev->pm_count_walk); in media_device_register_entity()
661 mdev->pm_count_walk = new; in media_device_register_entity()
663 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity()
671 struct media_device *mdev = entity->graph_obj.mdev; in media_device_unregister_entity() local
673 if (mdev == NULL) in media_device_unregister_entity()
676 mutex_lock(&mdev->graph_mutex); in media_device_unregister_entity()
678 mutex_unlock(&mdev->graph_mutex); in media_device_unregister_entity()
699 void media_device_init(struct media_device *mdev) in media_device_init() argument
701 INIT_LIST_HEAD(&mdev->entities); in media_device_init()
702 INIT_LIST_HEAD(&mdev->interfaces); in media_device_init()
703 INIT_LIST_HEAD(&mdev->pads); in media_device_init()
704 INIT_LIST_HEAD(&mdev->links); in media_device_init()
705 INIT_LIST_HEAD(&mdev->entity_notify); in media_device_init()
707 mutex_init(&mdev->req_queue_mutex); in media_device_init()
708 mutex_init(&mdev->graph_mutex); in media_device_init()
709 ida_init(&mdev->entity_internal_idx); in media_device_init()
711 atomic_set(&mdev->request_id, 0); in media_device_init()
713 if (!*mdev->bus_info) in media_device_init()
714 media_set_bus_info(mdev->bus_info, sizeof(mdev->bus_info), in media_device_init()
715 mdev->dev); in media_device_init()
717 atomic_set(&mdev->num_requests, 0); in media_device_init()
718 atomic_set(&mdev->num_request_objects, 0); in media_device_init()
720 dev_dbg(mdev->dev, "Media device initialized\n"); in media_device_init()
724 void media_device_cleanup(struct media_device *mdev) in media_device_cleanup() argument
726 ida_destroy(&mdev->entity_internal_idx); in media_device_cleanup()
727 mdev->entity_internal_idx_max = 0; in media_device_cleanup()
728 media_graph_walk_cleanup(&mdev->pm_count_walk); in media_device_cleanup()
729 mutex_destroy(&mdev->graph_mutex); in media_device_cleanup()
730 mutex_destroy(&mdev->req_queue_mutex); in media_device_cleanup()
734 int __must_check __media_device_register(struct media_device *mdev, in __media_device_register() argument
745 mdev->devnode = devnode; in __media_device_register()
747 devnode->parent = mdev->dev; in __media_device_register()
751 mdev->topology_version = 0; in __media_device_register()
753 ret = media_devnode_register(mdev, devnode, owner); in __media_device_register()
756 mdev->devnode = NULL; in __media_device_register()
763 mdev->devnode = NULL; in __media_device_register()
769 dev_dbg(mdev->dev, "Media device registered\n"); in __media_device_register()
774 mdev->media_dir = debugfs_create_dir(dev_name(&devnode->dev), in __media_device_register()
777 mdev->media_dir, media_device_requests); in __media_device_register()
784 void media_device_register_entity_notify(struct media_device *mdev, in media_device_register_entity_notify() argument
787 mutex_lock(&mdev->graph_mutex); in media_device_register_entity_notify()
788 list_add_tail(&nptr->list, &mdev->entity_notify); in media_device_register_entity_notify()
789 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity_notify()
794 * Note: Should be called with mdev->lock held.
796 static void __media_device_unregister_entity_notify(struct media_device *mdev, in __media_device_unregister_entity_notify() argument
802 void media_device_unregister_entity_notify(struct media_device *mdev, in media_device_unregister_entity_notify() argument
805 mutex_lock(&mdev->graph_mutex); in media_device_unregister_entity_notify()
806 __media_device_unregister_entity_notify(mdev, nptr); in media_device_unregister_entity_notify()
807 mutex_unlock(&mdev->graph_mutex); in media_device_unregister_entity_notify()
811 void media_device_unregister(struct media_device *mdev) in media_device_unregister() argument
818 if (mdev == NULL) in media_device_unregister()
821 mutex_lock(&mdev->graph_mutex); in media_device_unregister()
823 /* Check if mdev was ever registered at all */ in media_device_unregister()
824 if (!media_devnode_is_registered(mdev->devnode)) { in media_device_unregister()
825 mutex_unlock(&mdev->graph_mutex); in media_device_unregister()
830 media_devnode_unregister_prepare(mdev->devnode); in media_device_unregister()
833 list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) in media_device_unregister()
837 list_for_each_entry_safe(notify, nextp, &mdev->entity_notify, list) in media_device_unregister()
838 __media_device_unregister_entity_notify(mdev, notify); in media_device_unregister()
841 list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces, in media_device_unregister()
852 mutex_unlock(&mdev->graph_mutex); in media_device_unregister()
854 dev_dbg(mdev->dev, "Media device unregistered\n"); in media_device_unregister()
856 debugfs_remove_recursive(mdev->media_dir); in media_device_unregister()
857 device_remove_file(&mdev->devnode->dev, &dev_attr_model); in media_device_unregister()
858 media_devnode_unregister(mdev->devnode); in media_device_unregister()
860 mdev->devnode = NULL; in media_device_unregister()
865 void media_device_pci_init(struct media_device *mdev, in media_device_pci_init() argument
869 mdev->dev = &pci_dev->dev; in media_device_pci_init()
872 strscpy(mdev->model, name, sizeof(mdev->model)); in media_device_pci_init()
874 strscpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model)); in media_device_pci_init()
876 sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev)); in media_device_pci_init()
878 mdev->hw_revision = (pci_dev->subsystem_vendor << 16) in media_device_pci_init()
881 media_device_init(mdev); in media_device_pci_init()
887 void __media_device_usb_init(struct media_device *mdev, in __media_device_usb_init() argument
892 mdev->dev = &udev->dev; in __media_device_usb_init()
895 strscpy(mdev->driver_name, driver_name, in __media_device_usb_init()
896 sizeof(mdev->driver_name)); in __media_device_usb_init()
899 strscpy(mdev->model, board_name, sizeof(mdev->model)); in __media_device_usb_init()
901 strscpy(mdev->model, udev->product, sizeof(mdev->model)); in __media_device_usb_init()
903 strscpy(mdev->model, "unknown model", sizeof(mdev->model)); in __media_device_usb_init()
905 strscpy(mdev->serial, udev->serial, sizeof(mdev->serial)); in __media_device_usb_init()
906 usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info)); in __media_device_usb_init()
907 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); in __media_device_usb_init()
909 media_device_init(mdev); in __media_device_usb_init()