Lines Matching refs:mdev
84 static struct media_entity *find_entity(struct media_device *mdev, u32 id) in find_entity() argument
91 media_device_for_each_entity(entity, mdev) { in find_entity()
101 static long media_device_enum_entities(struct media_device *mdev, void *arg) in media_device_enum_entities() argument
106 ent = find_entity(mdev, entd->id); in media_device_enum_entities()
154 static long media_device_enum_links(struct media_device *mdev, void *arg) in media_device_enum_links() argument
159 entity = find_entity(mdev, links->entity); in media_device_enum_links()
202 static long media_device_setup_link(struct media_device *mdev, void *arg) in media_device_setup_link() argument
211 source = find_entity(mdev, linkd->source.entity); in media_device_setup_link()
212 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()
275 media_device_for_each_intf(intf, mdev) { in media_device_get_topology()
310 media_device_for_each_pad(pad, mdev) { in media_device_get_topology()
336 media_device_for_each_link(link, mdev) { in media_device_get_topology()
472 static long media_device_enum_links32(struct media_device *mdev, in media_device_enum_links32() argument
488 return media_device_enum_links(mdev, &links); in media_device_enum_links32()
534 struct media_device *mdev = devnode->media_dev; in show_model() local
536 return sprintf(buf, "%.*s\n", (int)sizeof(mdev->model), mdev->model); in show_model()
545 static void media_device_release(struct media_devnode *mdev) in media_device_release() argument
547 dev_dbg(mdev->parent, "Media device released\n"); in media_device_release()
555 int __must_check media_device_register_entity(struct media_device *mdev, in media_device_register_entity() argument
564 dev_warn(mdev->dev, in media_device_register_entity()
569 WARN_ON(entity->graph_obj.mdev != NULL); in media_device_register_entity()
570 entity->graph_obj.mdev = mdev; in media_device_register_entity()
575 if (!ida_pre_get(&mdev->entity_internal_idx, GFP_KERNEL)) in media_device_register_entity()
578 mutex_lock(&mdev->graph_mutex); in media_device_register_entity()
580 ret = ida_get_new_above(&mdev->entity_internal_idx, 1, in media_device_register_entity()
583 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity()
587 mdev->entity_internal_idx_max = in media_device_register_entity()
588 max(mdev->entity_internal_idx_max, entity->internal_idx); in media_device_register_entity()
591 media_gobj_create(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); in media_device_register_entity()
595 media_gobj_create(mdev, MEDIA_GRAPH_PAD, in media_device_register_entity()
599 list_for_each_entry_safe(notify, next, &mdev->entity_notify, list) { in media_device_register_entity()
603 if (mdev->entity_internal_idx_max in media_device_register_entity()
604 >= mdev->pm_count_walk.ent_enum.idx_max) { in media_device_register_entity()
612 ret = media_entity_graph_walk_init(&new, mdev); in media_device_register_entity()
614 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity()
617 media_entity_graph_walk_cleanup(&mdev->pm_count_walk); in media_device_register_entity()
618 mdev->pm_count_walk = new; in media_device_register_entity()
620 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity()
628 struct media_device *mdev = entity->graph_obj.mdev; in __media_device_unregister_entity() local
633 ida_simple_remove(&mdev->entity_internal_idx, entity->internal_idx); in __media_device_unregister_entity()
636 list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { in __media_device_unregister_entity()
655 entity->graph_obj.mdev = NULL; in __media_device_unregister_entity()
660 struct media_device *mdev = entity->graph_obj.mdev; in media_device_unregister_entity() local
662 if (mdev == NULL) in media_device_unregister_entity()
665 mutex_lock(&mdev->graph_mutex); in media_device_unregister_entity()
667 mutex_unlock(&mdev->graph_mutex); in media_device_unregister_entity()
681 void media_device_init(struct media_device *mdev) in media_device_init() argument
683 INIT_LIST_HEAD(&mdev->entities); in media_device_init()
684 INIT_LIST_HEAD(&mdev->interfaces); in media_device_init()
685 INIT_LIST_HEAD(&mdev->pads); in media_device_init()
686 INIT_LIST_HEAD(&mdev->links); in media_device_init()
687 INIT_LIST_HEAD(&mdev->entity_notify); in media_device_init()
688 mutex_init(&mdev->graph_mutex); in media_device_init()
689 ida_init(&mdev->entity_internal_idx); in media_device_init()
691 dev_dbg(mdev->dev, "Media device initialized\n"); in media_device_init()
695 void media_device_cleanup(struct media_device *mdev) in media_device_cleanup() argument
697 ida_destroy(&mdev->entity_internal_idx); in media_device_cleanup()
698 mdev->entity_internal_idx_max = 0; in media_device_cleanup()
699 media_entity_graph_walk_cleanup(&mdev->pm_count_walk); in media_device_cleanup()
700 mutex_destroy(&mdev->graph_mutex); in media_device_cleanup()
704 int __must_check __media_device_register(struct media_device *mdev, in __media_device_register() argument
715 mdev->devnode = devnode; in __media_device_register()
717 devnode->parent = mdev->dev; in __media_device_register()
721 mdev->topology_version = 0; in __media_device_register()
723 ret = media_devnode_register(mdev, devnode, owner); in __media_device_register()
726 mdev->devnode = NULL; in __media_device_register()
733 mdev->devnode = NULL; in __media_device_register()
739 dev_dbg(mdev->dev, "Media device registered\n"); in __media_device_register()
745 int __must_check media_device_register_entity_notify(struct media_device *mdev, in media_device_register_entity_notify() argument
748 mutex_lock(&mdev->graph_mutex); in media_device_register_entity_notify()
749 list_add_tail(&nptr->list, &mdev->entity_notify); in media_device_register_entity_notify()
750 mutex_unlock(&mdev->graph_mutex); in media_device_register_entity_notify()
758 static void __media_device_unregister_entity_notify(struct media_device *mdev, in __media_device_unregister_entity_notify() argument
764 void media_device_unregister_entity_notify(struct media_device *mdev, in media_device_unregister_entity_notify() argument
767 mutex_lock(&mdev->graph_mutex); in media_device_unregister_entity_notify()
768 __media_device_unregister_entity_notify(mdev, nptr); in media_device_unregister_entity_notify()
769 mutex_unlock(&mdev->graph_mutex); in media_device_unregister_entity_notify()
773 void media_device_unregister(struct media_device *mdev) in media_device_unregister() argument
780 if (mdev == NULL) in media_device_unregister()
783 mutex_lock(&mdev->graph_mutex); in media_device_unregister()
786 if (!media_devnode_is_registered(mdev->devnode)) { in media_device_unregister()
787 mutex_unlock(&mdev->graph_mutex); in media_device_unregister()
792 media_devnode_unregister_prepare(mdev->devnode); in media_device_unregister()
795 list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) in media_device_unregister()
799 list_for_each_entry_safe(notify, nextp, &mdev->entity_notify, list) in media_device_unregister()
800 __media_device_unregister_entity_notify(mdev, notify); in media_device_unregister()
803 list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces, in media_device_unregister()
810 mutex_unlock(&mdev->graph_mutex); in media_device_unregister()
812 dev_dbg(mdev->dev, "Media device unregistered\n"); in media_device_unregister()
814 device_remove_file(&mdev->devnode->dev, &dev_attr_model); in media_device_unregister()
815 media_devnode_unregister(mdev->devnode); in media_device_unregister()
817 mdev->devnode = NULL; in media_device_unregister()
827 struct media_device *mdev; in media_device_get_devres() local
829 mdev = devres_find(dev, media_device_release_devres, NULL, NULL); in media_device_get_devres()
830 if (mdev) in media_device_get_devres()
831 return mdev; in media_device_get_devres()
833 mdev = devres_alloc(media_device_release_devres, in media_device_get_devres()
835 if (!mdev) in media_device_get_devres()
837 return devres_get(dev, mdev, NULL, NULL); in media_device_get_devres()
848 void media_device_pci_init(struct media_device *mdev, in media_device_pci_init() argument
852 mdev->dev = &pci_dev->dev; in media_device_pci_init()
855 strlcpy(mdev->model, name, sizeof(mdev->model)); in media_device_pci_init()
857 strlcpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model)); in media_device_pci_init()
859 sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev)); in media_device_pci_init()
861 mdev->hw_revision = (pci_dev->subsystem_vendor << 16) in media_device_pci_init()
864 mdev->driver_version = LINUX_VERSION_CODE; in media_device_pci_init()
866 media_device_init(mdev); in media_device_pci_init()
872 void __media_device_usb_init(struct media_device *mdev, in __media_device_usb_init() argument
877 mdev->dev = &udev->dev; in __media_device_usb_init()
880 strlcpy(mdev->driver_name, driver_name, in __media_device_usb_init()
881 sizeof(mdev->driver_name)); in __media_device_usb_init()
884 strlcpy(mdev->model, board_name, sizeof(mdev->model)); in __media_device_usb_init()
886 strlcpy(mdev->model, udev->product, sizeof(mdev->model)); in __media_device_usb_init()
888 strlcpy(mdev->model, "unknown model", sizeof(mdev->model)); in __media_device_usb_init()
890 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial)); in __media_device_usb_init()
891 usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info)); in __media_device_usb_init()
892 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); in __media_device_usb_init()
893 mdev->driver_version = LINUX_VERSION_CODE; in __media_device_usb_init()
895 media_device_init(mdev); in __media_device_usb_init()