Lines Matching refs:mdev
88 static struct media_entity *find_entity(struct media_device *mdev, u32 id) in find_entity() argument
95 media_device_for_each_entity(entity, mdev) { in find_entity()
105 static long media_device_enum_entities(struct media_device *mdev, void *arg) in media_device_enum_entities() argument
110 ent = find_entity(mdev, entd->id); in media_device_enum_entities()
158 static long media_device_enum_links(struct media_device *mdev, void *arg) in media_device_enum_links() argument
163 entity = find_entity(mdev, links->entity); in media_device_enum_links()
207 static long media_device_setup_link(struct media_device *mdev, void *arg) in media_device_setup_link() argument
216 source = find_entity(mdev, linkd->source.entity); in media_device_setup_link()
217 sink = find_entity(mdev, linkd->sink.entity); in media_device_setup_link()
237 static long media_device_get_topology(struct media_device *mdev, void *arg) in media_device_get_topology() argument
251 topo->topology_version = mdev->topology_version; in media_device_get_topology()
256 media_device_for_each_entity(entity, mdev) { in media_device_get_topology()
284 media_device_for_each_intf(intf, mdev) { in media_device_get_topology()
320 media_device_for_each_pad(pad, mdev) { in media_device_get_topology()
348 media_device_for_each_link(link, mdev) { in media_device_get_topology()
485 static long media_device_enum_links32(struct media_device *mdev, in media_device_enum_links32() argument
501 return media_device_enum_links(mdev, &links); in media_device_enum_links32()
547 struct media_device *mdev = devnode->media_dev; in show_model() local
549 return sprintf(buf, "%.*s\n", (int)sizeof(mdev->model), mdev->model); in show_model()
568 int __must_check media_device_register_entity(struct media_device *mdev, in media_device_register_entity() argument
577 dev_warn(mdev->dev, in media_device_register_entity()
582 WARN_ON(entity->graph_obj.mdev != NULL); in media_device_register_entity()
583 entity->graph_obj.mdev = mdev; in media_device_register_entity()
588 ret = ida_alloc_min(&mdev->entity_internal_idx, 1, GFP_KERNEL); in media_device_register_entity()
593 mutex_lock(&mdev->graph_mutex); in media_device_register_entity()
594 mdev->entity_internal_idx_max = in media_device_register_entity()
595 max(mdev->entity_internal_idx_max, entity->internal_idx); in media_device_register_entity()
598 media_gobj_create(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); in media_device_register_entity()
602 media_gobj_create(mdev, MEDIA_GRAPH_PAD, in media_device_register_entity()
606 list_for_each_entry_safe(notify, next, &mdev->entity_notify, list) in media_device_register_entity()
609 if (mdev->entity_internal_idx_max in media_device_register_entity()
610 >= mdev->pm_count_walk.ent_enum.idx_max) { in media_device_register_entity()
618 ret = media_graph_walk_init(&new, mdev); in media_device_register_entity()
620 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity()
623 media_graph_walk_cleanup(&mdev->pm_count_walk); in media_device_register_entity()
624 mdev->pm_count_walk = new; in media_device_register_entity()
626 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity()
634 struct media_device *mdev = entity->graph_obj.mdev; in __media_device_unregister_entity() local
639 ida_free(&mdev->entity_internal_idx, entity->internal_idx); in __media_device_unregister_entity()
642 list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { in __media_device_unregister_entity()
661 entity->graph_obj.mdev = NULL; in __media_device_unregister_entity()
666 struct media_device *mdev = entity->graph_obj.mdev; in media_device_unregister_entity() local
668 if (mdev == NULL) in media_device_unregister_entity()
671 mutex_lock(&mdev->graph_mutex); in media_device_unregister_entity()
673 mutex_unlock(&mdev->graph_mutex); in media_device_unregister_entity()
687 void media_device_init(struct media_device *mdev) in media_device_init() argument
689 INIT_LIST_HEAD(&mdev->entities); in media_device_init()
690 INIT_LIST_HEAD(&mdev->interfaces); in media_device_init()
691 INIT_LIST_HEAD(&mdev->pads); in media_device_init()
692 INIT_LIST_HEAD(&mdev->links); in media_device_init()
693 INIT_LIST_HEAD(&mdev->entity_notify); in media_device_init()
694 mutex_init(&mdev->graph_mutex); in media_device_init()
695 ida_init(&mdev->entity_internal_idx); in media_device_init()
697 dev_dbg(mdev->dev, "Media device initialized\n"); in media_device_init()
701 void media_device_cleanup(struct media_device *mdev) in media_device_cleanup() argument
703 ida_destroy(&mdev->entity_internal_idx); in media_device_cleanup()
704 mdev->entity_internal_idx_max = 0; in media_device_cleanup()
705 media_graph_walk_cleanup(&mdev->pm_count_walk); in media_device_cleanup()
706 mutex_destroy(&mdev->graph_mutex); in media_device_cleanup()
710 int __must_check __media_device_register(struct media_device *mdev, in __media_device_register() argument
721 mdev->devnode = devnode; in __media_device_register()
723 devnode->parent = mdev->dev; in __media_device_register()
727 mdev->topology_version = 0; in __media_device_register()
729 ret = media_devnode_register(mdev, devnode, owner); in __media_device_register()
732 mdev->devnode = NULL; in __media_device_register()
739 mdev->devnode = NULL; in __media_device_register()
745 dev_dbg(mdev->dev, "Media device registered\n"); in __media_device_register()
751 int __must_check media_device_register_entity_notify(struct media_device *mdev, in media_device_register_entity_notify() argument
754 mutex_lock(&mdev->graph_mutex); in media_device_register_entity_notify()
755 list_add_tail(&nptr->list, &mdev->entity_notify); in media_device_register_entity_notify()
756 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity_notify()
764 static void __media_device_unregister_entity_notify(struct media_device *mdev, in __media_device_unregister_entity_notify() argument
770 void media_device_unregister_entity_notify(struct media_device *mdev, in media_device_unregister_entity_notify() argument
773 mutex_lock(&mdev->graph_mutex); in media_device_unregister_entity_notify()
774 __media_device_unregister_entity_notify(mdev, nptr); in media_device_unregister_entity_notify()
775 mutex_unlock(&mdev->graph_mutex); in media_device_unregister_entity_notify()
779 void media_device_unregister(struct media_device *mdev) in media_device_unregister() argument
786 if (mdev == NULL) in media_device_unregister()
789 mutex_lock(&mdev->graph_mutex); in media_device_unregister()
792 if (!media_devnode_is_registered(mdev->devnode)) { in media_device_unregister()
793 mutex_unlock(&mdev->graph_mutex); in media_device_unregister()
798 media_devnode_unregister_prepare(mdev->devnode); in media_device_unregister()
801 list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) in media_device_unregister()
805 list_for_each_entry_safe(notify, nextp, &mdev->entity_notify, list) in media_device_unregister()
806 __media_device_unregister_entity_notify(mdev, notify); in media_device_unregister()
809 list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces, in media_device_unregister()
820 mutex_unlock(&mdev->graph_mutex); in media_device_unregister()
822 dev_dbg(mdev->dev, "Media device unregistered\n"); in media_device_unregister()
824 device_remove_file(&mdev->devnode->dev, &dev_attr_model); in media_device_unregister()
825 media_devnode_unregister(mdev->devnode); in media_device_unregister()
827 mdev->devnode = NULL; in media_device_unregister()
832 void media_device_pci_init(struct media_device *mdev, in media_device_pci_init() argument
836 mdev->dev = &pci_dev->dev; in media_device_pci_init()
839 strlcpy(mdev->model, name, sizeof(mdev->model)); in media_device_pci_init()
841 strlcpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model)); in media_device_pci_init()
843 sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev)); in media_device_pci_init()
845 mdev->hw_revision = (pci_dev->subsystem_vendor << 16) in media_device_pci_init()
848 media_device_init(mdev); in media_device_pci_init()
854 void __media_device_usb_init(struct media_device *mdev, in __media_device_usb_init() argument
859 mdev->dev = &udev->dev; in __media_device_usb_init()
862 strlcpy(mdev->driver_name, driver_name, in __media_device_usb_init()
863 sizeof(mdev->driver_name)); in __media_device_usb_init()
866 strlcpy(mdev->model, board_name, sizeof(mdev->model)); in __media_device_usb_init()
868 strlcpy(mdev->model, udev->product, sizeof(mdev->model)); in __media_device_usb_init()
870 strlcpy(mdev->model, "unknown model", sizeof(mdev->model)); in __media_device_usb_init()
872 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial)); in __media_device_usb_init()
873 usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info)); in __media_device_usb_init()
874 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); in __media_device_usb_init()
876 media_device_init(mdev); in __media_device_usb_init()