€•÷GŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ"/translations/zh_CN/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/zh_TW/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/it_IT/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ja_JP/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ko_KR/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/sp_SP/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒHow FunctionFS works”h]”hŒHow FunctionFS works”…””}”(hh¨hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh£hžhhŸŒ iSerialNumber= functions=mtp,hid $ mkdir /dev/ffs-mtp && mount -t functionfs mtp /dev/ffs-mtp $ ( cd /dev/ffs-mtp && mtp-daemon ) & $ mkdir /dev/ffs-hid && mount -t functionfs hid /dev/ffs-hid $ ( cd /dev/ffs-hid && hid-daemon ) &”h]”hX$ insmod g_ffs.ko idVendor= iSerialNumber= functions=mtp,hid $ mkdir /dev/ffs-mtp && mount -t functionfs mtp /dev/ffs-mtp $ ( cd /dev/ffs-mtp && mtp-daemon ) & $ mkdir /dev/ffs-hid && mount -t functionfs hid /dev/ffs-hid $ ( cd /dev/ffs-hid && hid-daemon ) &”…””}”hjasbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j_hŸh¶h K2hh·hžhubhÉ)”}”(hŒƒOn kernel level the gadget checks ffs_data->dev_name to identify whether its FunctionFS is designed for MTP ("mtp") or HID ("hid").”h]”hŒ‹On kernel level the gadget checks ffs_data->dev_name to identify whether its FunctionFS is designed for MTP (“mtpâ€) or HID (“hidâ€).”…””}”(hjqhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K8hh·hžhubhÉ)”}”(hŒdIf no "functions" module parameters is supplied, the driver accepts just one function with any name.”h]”hŒhIf no “functions†module parameters is supplied, the driver accepts just one function with any name.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K;hh·hžhubhÉ)”}”(hX1When "functions" module parameter is supplied, only functions with listed names are accepted. In particular, if the "functions" parameter's value is just a one-element list, then the behaviour is similar to when there is no "functions" at all; however, only a function with the specified name is accepted.”h]”hX?When “functions†module parameter is supplied, only functions with listed names are accepted. In particular, if the “functions†parameter’s value is just a one-element list, then the behaviour is similar to when there is no “functions†at all; however, only a function with the specified name is accepted.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K>hh·hžhubhÉ)”}”(hŒ¢The gadget is registered only after all the declared function filesystems have been mounted and USB descriptors of all functions have been written to their ep0's.”h]”hŒ¤The gadget is registered only after all the declared function filesystems have been mounted and USB descriptors of all functions have been written to their ep0’s.”…””}”(hj›hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KDhh·hžhubhÉ)”}”(hŒYConversely, the gadget is unregistered after the first USB function closes its endpoints.”h]”hŒYConversely, the gadget is unregistered after the first USB function closes its endpoints.”…””}”(hj©hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KHhh·hžhubeh}”(h]”Œoverview”ah ]”h"]”Œoverview”ah$]”h&]”uh1h¡hh£hžhhŸh¶h Kubh¢)”}”(hhh]”(h§)”}”(hŒDMABUF interface”h]”hŒDMABUF interface”…””}”(hjÂhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hj¿hžhhŸh¶h KLubhÉ)”}”(hŒ»FunctionFS additionally supports a DMABUF based interface, where the userspace can attach DMABUF objects (externally created) to an endpoint, and subsequently use them for data transfers.”h]”hŒ»FunctionFS additionally supports a DMABUF based interface, where the userspace can attach DMABUF objects (externally created) to an endpoint, and subsequently use them for data transfers.”…””}”(hjÐhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KNhj¿hžhubhÉ)”}”(hŒÈA userspace application can then use this interface to share DMABUF objects between several interfaces, allowing it to transfer data in a zero-copy fashion, for instance between IIO and the USB stack.”h]”hŒÈA userspace application can then use this interface to share DMABUF objects between several interfaces, allowing it to transfer data in a zero-copy fashion, for instance between IIO and the USB stack.”…””}”(hjÞhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KRhj¿hžhubhÉ)”}”(hŒAs part of this interface, three new IOCTLs have been added. These three IOCTLs have to be performed on a data endpoint (ie. not ep0). They are:”h]”hŒAs part of this interface, three new IOCTLs have been added. These three IOCTLs have to be performed on a data endpoint (ie. not ep0). They are:”…””}”(hjìhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KVhj¿hžhubhŒ block_quote”“”)”}”(hXz``FUNCTIONFS_DMABUF_ATTACH(int)`` Attach the DMABUF object, identified by its file descriptor, to the data endpoint. Returns zero on success, and a negative errno value on error. ``FUNCTIONFS_DMABUF_DETACH(int)`` Detach the given DMABUF object, identified by its file descriptor, from the data endpoint. Returns zero on success, and a negative errno value on error. Note that closing the endpoint's file descriptor will automatically detach all attached DMABUFs. ``FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)`` Enqueue the previously attached DMABUF to the transfer queue. The argument is a structure that packs the DMABUF's file descriptor, the size in bytes to transfer (which should generally correspond to the size of the DMABUF), and a 'flags' field which is unused for now. Returns zero on success, and a negative errno value on error.”h]”hŒdefinition_list”“”)”}”(hhh]”(hŒdefinition_list_item”“”)”}”(hŒ³``FUNCTIONFS_DMABUF_ATTACH(int)`` Attach the DMABUF object, identified by its file descriptor, to the data endpoint. Returns zero on success, and a negative errno value on error. ”h]”(hŒterm”“”)”}”(hŒ!``FUNCTIONFS_DMABUF_ATTACH(int)``”h]”hŒliteral”“”)”}”(hjh]”hŒFUNCTIONFS_DMABUF_ATTACH(int)”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1j hŸh¶h K\hjubhŒ definition”“”)”}”(hhh]”hÉ)”}”(hŒAttach the DMABUF object, identified by its file descriptor, to the data endpoint. Returns zero on success, and a negative errno value on error.”h]”hŒAttach the DMABUF object, identified by its file descriptor, to the data endpoint. Returns zero on success, and a negative errno value on error.”…””}”(hj+hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KZhj(ubah}”(h]”h ]”h"]”h$]”h&]”uh1j&hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h K\hjubj)”}”(hX``FUNCTIONFS_DMABUF_DETACH(int)`` Detach the given DMABUF object, identified by its file descriptor, from the data endpoint. Returns zero on success, and a negative errno value on error. Note that closing the endpoint's file descriptor will automatically detach all attached DMABUFs. ”h]”(j )”}”(hŒ!``FUNCTIONFS_DMABUF_DETACH(int)``”h]”j)”}”(hjKh]”hŒFUNCTIONFS_DMABUF_DETACH(int)”…””}”(hjMhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjIubah}”(h]”h ]”h"]”h$]”h&]”uh1j hŸh¶h KbhjEubj')”}”(hhh]”hÉ)”}”(hŒùDetach the given DMABUF object, identified by its file descriptor, from the data endpoint. Returns zero on success, and a negative errno value on error. Note that closing the endpoint's file descriptor will automatically detach all attached DMABUFs.”h]”hŒûDetach the given DMABUF object, identified by its file descriptor, from the data endpoint. Returns zero on success, and a negative errno value on error. Note that closing the endpoint’s file descriptor will automatically detach all attached DMABUFs.”…””}”(hjchžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K_hj`ubah}”(h]”h ]”h"]”h$]”h&]”uh1j&hjEubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h Kbhjubj)”}”(hX``FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)`` Enqueue the previously attached DMABUF to the transfer queue. The argument is a structure that packs the DMABUF's file descriptor, the size in bytes to transfer (which should generally correspond to the size of the DMABUF), and a 'flags' field which is unused for now. Returns zero on success, and a negative errno value on error.”h]”(j )”}”(hŒD``FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)``”h]”j)”}”(hjƒh]”hŒ@FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)”…””}”(hj…hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubah}”(h]”h ]”h"]”h$]”h&]”uh1j hŸh¶h Kihj}ubj')”}”(hhh]”hÉ)”}”(hXJEnqueue the previously attached DMABUF to the transfer queue. The argument is a structure that packs the DMABUF's file descriptor, the size in bytes to transfer (which should generally correspond to the size of the DMABUF), and a 'flags' field which is unused for now. Returns zero on success, and a negative errno value on error.”h]”hXPEnqueue the previously attached DMABUF to the transfer queue. The argument is a structure that packs the DMABUF’s file descriptor, the size in bytes to transfer (which should generally correspond to the size of the DMABUF), and a ‘flags’ field which is unused for now. Returns zero on success, and a negative errno value on error.”…””}”(hj›hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h Kehj˜ubah}”(h]”h ]”h"]”h$]”h&]”uh1j&hj}ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h Kihjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjüubah}”(h]”h ]”h"]”h$]”h&]”uh1júhŸh¶h KYhj¿hžhubeh}”(h]”Œdmabuf-interface”ah ]”h"]”Œdmabuf interface”ah$]”h&]”uh1h¡hh£hžhhŸh¶h KLubeh}”(h]”Œhow-functionfs-works”ah ]”h"]”Œhow functionfs works”ah$]”h&]”uh1h¡hhhžhhŸh¶h Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h¶uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(h¦NŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jôŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h¶Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jÎjËj¼j¹jÆjÃuŒ nametypes”}”(jΉj¼‰jƉuh}”(jËh£j¹h·jÃj¿uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.